From e93286d6da5867089e5248a9137a20a53b93f4e3 Mon Sep 17 00:00:00 2001 From: "Daniel C. Marcu" Date: Fri, 23 Sep 2016 22:10:36 +0100 Subject: [PATCH 1/6] DOC updated hexbin documentation to numpydoc format. --- lib/matplotlib/axes/_axes.py | 243 +++++++++++++++++++---------------- 1 file changed, 129 insertions(+), 114 deletions(-) diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index bc06f8391a84..72ff28c5b376 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -4083,15 +4083,6 @@ def hexbin(self, x, y, C=None, gridsize=100, bins=None, """ Make a hexagonal binning plot. - Call signature:: - - hexbin(x, y, C = None, gridsize = 100, bins = None, - xscale = 'linear', yscale = 'linear', - cmap=None, norm=None, vmin=None, vmax=None, - alpha=None, linewidths=None, edgecolors='none' - reduce_C_function = np.mean, mincnt=None, marginals=True - **kwargs) - Make a hexagonal binning plot of *x* versus *y*, where *x*, *y* are 1-D sequences of the same length, *N*. If *C* is *None* (the default), this is a histogram of the number of occurences @@ -4103,113 +4094,137 @@ def hexbin(self, x, y, C=None, gridsize=100, bins=None, defaults to numpy's mean function (np.mean). (If *C* is specified, it must also be a 1-D sequence of the same length as *x* and *y*.) - - *x*, *y* and/or *C* may be masked arrays, in which case only - unmasked points will be plotted. - - Optional keyword arguments: - - *gridsize*: [ 100 | integer ] - The number of hexagons in the *x*-direction, default is - 100. The corresponding number of hexagons in the - *y*-direction is chosen such that the hexagons are - approximately regular. Alternatively, gridsize can be a - tuple with two elements specifying the number of hexagons - in the *x*-direction and the *y*-direction. - - *bins*: [ *None* | 'log' | integer | sequence ] - If *None*, no binning is applied; the color of each hexagon - directly corresponds to its count value. - - If 'log', use a logarithmic scale for the color - map. Internally, :math:`log_{10}(i+1)` is used to - determine the hexagon color. - - If an integer, divide the counts in the specified number - of bins, and color the hexagons accordingly. - - If a sequence of values, the values of the lower bound of - the bins to be used. - - *xscale*: [ 'linear' | 'log' ] - Use a linear or log10 scale on the horizontal axis. - - *yscale*: [ 'linear' | 'log' ] - Use a linear or log10 scale on the vertical axis. - - *mincnt*: [ *None* | a positive integer ] - If not *None*, only display cells with more than *mincnt* - number of points in the cell - - *marginals*: [ *True* | *False* ] - if marginals is *True*, plot the marginal density as - colormapped rectagles along the bottom of the x-axis and - left of the y-axis - - *extent*: [ *None* | scalars (left, right, bottom, top) ] - The limits of the bins. The default assigns the limits - based on *gridsize*, *x*, *y*, *xscale* and *yscale*. - - If *xscale* or *yscale* is set to 'log', the limits are - expected to be the exponent for a power of 10. E.g. for - x-limits of 1 and 50 in 'linear' scale and y-limits - of 10 and 1000 in 'log' scale, enter (1, 50, 1, 3). - + + Parameters + ---------- + x : array + may be masked array, in which case only unmasked points + will be plotted + + y : array + may be masked array, in which case only unmasked points + will be plotted + + C : array + may be masked array, in which case only unmasked points + will be plotted + + gridsize : int, optional + The number of hexagons in the *x*-direction, default is + 100. The corresponding number of hexagons in the + *y*-direction is chosen such that the hexagons are + approximately regular. Alternatively, gridsize can be a + tuple with two elements specifying the number of hexagons + in the *x*-direction and the *y*-direction. + + bins : {'log'} or int or sequence, optional + If *None*, no binning is applied; the color of each hexagon + directly corresponds to its count value. + + If 'log', use a logarithmic scale for the color + map. Internally, :math:`log_{10}(i+1)` is used to + determine the hexagon color. + + If an integer, divide the counts in the specified number + of bins, and color the hexagons accordingly. + + If a sequence of values, the values of the lower bound of + the bins to be used. + + xscale : {'linear', 'log'}, optional + Use a linear or log10 scale on the horizontal axis. + + yscale : {'linear', 'log'}, optional + Use a linear or log10 scale on the vertical axis. + + mincnt : int > 0, optional + If not *None*, only display cells with more than *mincnt* + number of points in the cell + + marginals : bool, optional + if marginals is *True*, plot the marginal density as + colormapped rectagles along the bottom of the x-axis and + left of the y-axis + + extent : scalar, optional + The limits of the bins. The default assigns the limits + based on *gridsize*, *x*, *y*, *xscale* and *yscale*. + + If *xscale* or *yscale* is set to 'log', the limits are + expected to be the exponent for a power of 10. E.g. for + x-limits of 1 and 50 in 'linear' scale and y-limits + of 10 and 1000 in 'log' scale, enter (1, 50, 1, 3). + + Order of scalars is (left, right, bottom, top). + + Other parameters + ---------------- Other keyword arguments controlling color mapping and normalization - arguments: - - *cmap*: [ *None* | Colormap ] - a :class:`matplotlib.colors.Colormap` instance. If *None*, - defaults to rc ``image.cmap``. - - *norm*: [ *None* | Normalize ] - :class:`matplotlib.colors.Normalize` instance is used to - scale luminance data to 0,1. - - *vmin* / *vmax*: scalar - *vmin* and *vmax* are used in conjunction with *norm* to normalize - luminance data. If either are *None*, the min and max of the color - array *C* is used. Note if you pass a norm instance, your settings - for *vmin* and *vmax* will be ignored. - - *alpha*: scalar between 0 and 1, or *None* - the alpha value for the patches - - *linewidths*: [ *None* | scalar ] - If *None*, defaults to 1.0. Note that this is a tuple, and - if you set the linewidths argument you must set it as a - sequence of floats, as required by - :class:`~matplotlib.collections.RegularPolyCollection`. - - Other keyword arguments controlling the Collection properties: - - *edgecolors*: [ *None* | ``'none'`` | mpl color | color sequence ] - If ``'none'``, draws the edges in the same color as the fill color. - This is the default, as it avoids unsightly unpainted pixels - between the hexagons. - - If *None*, draws the outlines in the default color. - - If a matplotlib color arg or sequence of rgba tuples, draws the - outlines in the specified color. - - Here are the standard descriptions of all the - :class:`~matplotlib.collections.Collection` kwargs: - - %(Collection)s - - The return value is a - :class:`~matplotlib.collections.PolyCollection` instance; use - :meth:`~matplotlib.collections.PolyCollection.get_array` on - this :class:`~matplotlib.collections.PolyCollection` to get - the counts in each hexagon. If *marginals* is *True*, horizontal - bar and vertical bar (both PolyCollections) will be attached - to the return collection as attributes *hbar* and *vbar*. - - - **Example:** - + arguments. + + cmap : object, optional + a :class:`matplotlib.colors.Colormap` instance. If *None*, + defaults to rc ``image.cmap``. + + norm : object, optional + :class:`matplotlib.colors.Normalize` instance is used to + scale luminance data to 0,1. + + vmin : scalar, optional + *vmin* is used in conjunction with *norm* to normalize + luminance data. If *None*, the min of the color array *C* + is used. Note if you pass a norm instance, your settings + for *vmin* will be ignored. + + vmax : scalar, optional + *vmax* is used in conjunction with *norm* to normalize + luminance data. If *None*, the max of the color array *C* + is used. Note if you pass a norm instance, your settings + for *vmax* will be ignored. + + alpha : scalar between 0 and 1, optional + the alpha value for the patches + + linewidths : scalar, optional + If *None*, defaults to 1.0. Note that this is a tuple, and + if you set the linewidths argument you must set it as a + sequence of floats, as required by + :class:`~matplotlib.collections.RegularPolyCollection`. + + Other keyword arguments controlling the Collection properties. + + edgecolors : {'none'}, mpl color, color sequence, optional + If 'none', draws the edges in the same color as the fill color. + This is the default, as it avoids unsightly unpainted pixels + between the hexagons. + + If *None*, draws the outlines in the default color. + + If a matplotlib color arg or sequence of rgba tuples, draws the + outlines in the specified color. + + Returns + ------- + object + a :class:`~matplotlib.collections.PolyCollection` instance; use + :meth:`~matplotlib.collections.PolyCollection.get_array` on + this :class:`~matplotlib.collections.PolyCollection` to get + the counts in each hexagon. + + If *marginals* is *True*, horizontal + bar and vertical bar (both PolyCollections) will be attached + to the return collection as attributes *hbar* and *vbar*. + + Examples + -------- .. plot:: mpl_examples/pylab_examples/hexbin_demo.py + + See also + -------- + The standard descriptions of all the + :class:`~matplotlib.collections.Collection` parameters: + + %(Collection)s """ From dfa9f6fe1f6344757bedd098106e5a49e6bbeb92 Mon Sep 17 00:00:00 2001 From: "Daniel C. Marcu" Date: Sun, 25 Sep 2016 22:12:13 +0100 Subject: [PATCH 2/6] DOC fixed pep8 compliance, added parameter defaults, fixed parsing issues --- lib/matplotlib/axes/_axes.py | 61 +++++++++++++++++------------------- 1 file changed, 28 insertions(+), 33 deletions(-) diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index 72ff28c5b376..7a3b8eb3e8d9 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -4094,22 +4094,22 @@ def hexbin(self, x, y, C=None, gridsize=100, bins=None, defaults to numpy's mean function (np.mean). (If *C* is specified, it must also be a 1-D sequence of the same length as *x* and *y*.) - + Parameters ---------- x : array may be masked array, in which case only unmasked points will be plotted - + y : array may be masked array, in which case only unmasked points will be plotted - - C : array + + C : array, default is *None* may be masked array, in which case only unmasked points will be plotted - gridsize : int, optional + gridsize : int, optional, default is 100 The number of hexagons in the *x*-direction, default is 100. The corresponding number of hexagons in the *y*-direction is chosen such that the hexagons are @@ -4117,7 +4117,7 @@ def hexbin(self, x, y, C=None, gridsize=100, bins=None, tuple with two elements specifying the number of hexagons in the *x*-direction and the *y*-direction. - bins : {'log'} or int or sequence, optional + bins : {'log'} or int or sequence, optional, default is *None* If *None*, no binning is applied; the color of each hexagon directly corresponds to its count value. @@ -4131,22 +4131,22 @@ def hexbin(self, x, y, C=None, gridsize=100, bins=None, If a sequence of values, the values of the lower bound of the bins to be used. - xscale : {'linear', 'log'}, optional + xscale : {'linear', 'log'}, optional, default is 'linear' Use a linear or log10 scale on the horizontal axis. - yscale : {'linear', 'log'}, optional + yscale : {'linear', 'log'}, optional, default is 'linear' Use a linear or log10 scale on the vertical axis. - mincnt : int > 0, optional + mincnt : int > 0, optional, default is *None* If not *None*, only display cells with more than *mincnt* number of points in the cell - marginals : bool, optional + marginals : bool, optional, default is *False* if marginals is *True*, plot the marginal density as colormapped rectagles along the bottom of the x-axis and left of the y-axis - extent : scalar, optional + extent : scalar, optional, default is *None* The limits of the bins. The default assigns the limits based on *gridsize*, *x*, *y*, *xscale* and *yscale*. @@ -4154,46 +4154,41 @@ def hexbin(self, x, y, C=None, gridsize=100, bins=None, expected to be the exponent for a power of 10. E.g. for x-limits of 1 and 50 in 'linear' scale and y-limits of 10 and 1000 in 'log' scale, enter (1, 50, 1, 3). - + Order of scalars is (left, right, bottom, top). - + Other parameters ---------------- - Other keyword arguments controlling color mapping and normalization - arguments. - - cmap : object, optional + cmap : object, optional, default is *None* a :class:`matplotlib.colors.Colormap` instance. If *None*, defaults to rc ``image.cmap``. - - norm : object, optional + + norm : object, optional, default is *None* :class:`matplotlib.colors.Normalize` instance is used to scale luminance data to 0,1. - vmin : scalar, optional - *vmin* is used in conjunction with *norm* to normalize + vmin : scalar, optional, default is *None* + *vmin* is used in conjunction with *norm* to normalize luminance data. If *None*, the min of the color array *C* is used. Note if you pass a norm instance, your settings for *vmin* will be ignored. - - vmax : scalar, optional + + vmax : scalar, optional, default is *None* *vmax* is used in conjunction with *norm* to normalize luminance data. If *None*, the max of the color array *C* is used. Note if you pass a norm instance, your settings for *vmax* will be ignored. - alpha : scalar between 0 and 1, optional + alpha : scalar between 0 and 1, optional, default is *None* the alpha value for the patches - linewidths : scalar, optional + linewidths : scalar, optional, default is *None* If *None*, defaults to 1.0. Note that this is a tuple, and if you set the linewidths argument you must set it as a sequence of floats, as required by :class:`~matplotlib.collections.RegularPolyCollection`. - Other keyword arguments controlling the Collection properties. - - edgecolors : {'none'}, mpl color, color sequence, optional + edgecolors : {'none'}, mpl color, color sequence, optional, default is 'none' If 'none', draws the edges in the same color as the fill color. This is the default, as it avoids unsightly unpainted pixels between the hexagons. @@ -4202,7 +4197,7 @@ def hexbin(self, x, y, C=None, gridsize=100, bins=None, If a matplotlib color arg or sequence of rgba tuples, draws the outlines in the specified color. - + Returns ------- object @@ -4210,16 +4205,16 @@ def hexbin(self, x, y, C=None, gridsize=100, bins=None, :meth:`~matplotlib.collections.PolyCollection.get_array` on this :class:`~matplotlib.collections.PolyCollection` to get the counts in each hexagon. - + If *marginals* is *True*, horizontal bar and vertical bar (both PolyCollections) will be attached to the return collection as attributes *hbar* and *vbar*. - + Examples -------- .. plot:: mpl_examples/pylab_examples/hexbin_demo.py - - See also + + Notes -------- The standard descriptions of all the :class:`~matplotlib.collections.Collection` parameters: From 22acb50c5ce2234e4737cbaf740f2e3ab4816f2f Mon Sep 17 00:00:00 2001 From: "Daniel C. Marcu" Date: Sun, 25 Sep 2016 23:59:05 +0100 Subject: [PATCH 3/6] DOC fixed pep8 conformance issue on line 4183 (line too long), made it two lines --- lib/matplotlib/axes/_axes.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index 7a3b8eb3e8d9..c89beac20a2b 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -4188,7 +4188,8 @@ def hexbin(self, x, y, C=None, gridsize=100, bins=None, sequence of floats, as required by :class:`~matplotlib.collections.RegularPolyCollection`. - edgecolors : {'none'}, mpl color, color sequence, optional, default is 'none' + edgecolors : {'none'}, mpl color, color sequence, optional, + default is 'none' If 'none', draws the edges in the same color as the fill color. This is the default, as it avoids unsightly unpainted pixels between the hexagons. From d0aa9ae08676d04192b7f5d067fb9da46a8f67d6 Mon Sep 17 00:00:00 2001 From: "Daniel C. Marcu" Date: Mon, 26 Sep 2016 22:48:59 +0100 Subject: [PATCH 4/6] DOC Reduced repetitions, made corrections on linewidths and edgecolors --- lib/matplotlib/axes/_axes.py | 39 +++++++++--------------------------- 1 file changed, 10 insertions(+), 29 deletions(-) diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index c89beac20a2b..922a161edfae 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -4097,17 +4097,9 @@ def hexbin(self, x, y, C=None, gridsize=100, bins=None, Parameters ---------- - x : array - may be masked array, in which case only unmasked points - will be plotted - - y : array - may be masked array, in which case only unmasked points - will be plotted + x, y : array, masked array - C : array, default is *None* - may be masked array, in which case only unmasked points - will be plotted + C : array, masked array, optional, default is *None* gridsize : int, optional, default is 100 The number of hexagons in the *x*-direction, default is @@ -4167,37 +4159,26 @@ def hexbin(self, x, y, C=None, gridsize=100, bins=None, :class:`matplotlib.colors.Normalize` instance is used to scale luminance data to 0,1. - vmin : scalar, optional, default is *None* - *vmin* is used in conjunction with *norm* to normalize - luminance data. If *None*, the min of the color array *C* - is used. Note if you pass a norm instance, your settings - for *vmin* will be ignored. - - vmax : scalar, optional, default is *None* - *vmax* is used in conjunction with *norm* to normalize - luminance data. If *None*, the max of the color array *C* - is used. Note if you pass a norm instance, your settings - for *vmax* will be ignored. + vmin, vmax : scalar, optional, default is *None* + *vmin* and *vmax* are used in conjunction with *norm* to + normalize luminance data. If *None*, the min and max of the + color array *C* are used. Note if you pass a norm instance + your settings for *vmin* and *vmax* will be ignored. alpha : scalar between 0 and 1, optional, default is *None* the alpha value for the patches linewidths : scalar, optional, default is *None* - If *None*, defaults to 1.0. Note that this is a tuple, and - if you set the linewidths argument you must set it as a - sequence of floats, as required by - :class:`~matplotlib.collections.RegularPolyCollection`. + If *None*, defaults to 1.0. - edgecolors : {'none'}, mpl color, color sequence, optional, - default is 'none' + edgecolors : {'none'}, mpl color, optional, default is 'none' If 'none', draws the edges in the same color as the fill color. This is the default, as it avoids unsightly unpainted pixels between the hexagons. If *None*, draws the outlines in the default color. - If a matplotlib color arg or sequence of rgba tuples, draws the - outlines in the specified color. + If a matplotlib color arg, draws the outlines in the specified color. Returns ------- From d43caeca55a196b5ebefa97c25777e9c0ab8b4d8 Mon Sep 17 00:00:00 2001 From: "Daniel C. Marcu" Date: Tue, 27 Sep 2016 00:03:19 +0100 Subject: [PATCH 5/6] Fixed line 4173 for pep8 conformance --- lib/matplotlib/axes/_axes.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index 922a161edfae..6c10645ece7f 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -4176,9 +4176,9 @@ def hexbin(self, x, y, C=None, gridsize=100, bins=None, This is the default, as it avoids unsightly unpainted pixels between the hexagons. - If *None*, draws the outlines in the default color. + If *None*, draws outlines in the default color. - If a matplotlib color arg, draws the outlines in the specified color. + If a matplotlib color arg, draws outlines in the specified color. Returns ------- From 465f7b2b0307dc2f91b0da90dc74a86283b0d52d Mon Sep 17 00:00:00 2001 From: "Daniel C. Marcu" Date: Tue, 27 Sep 2016 23:39:11 +0100 Subject: [PATCH 6/6] DOC Updated gridsize description, language consistency where multiple inputs possible --- lib/matplotlib/axes/_axes.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index 6c10645ece7f..02b9ddd5af5f 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -4097,11 +4097,11 @@ def hexbin(self, x, y, C=None, gridsize=100, bins=None, Parameters ---------- - x, y : array, masked array + x, y : array or masked array - C : array, masked array, optional, default is *None* + C : array or masked array, optional, default is *None* - gridsize : int, optional, default is 100 + gridsize : int or (int, int), optional, default is 100 The number of hexagons in the *x*-direction, default is 100. The corresponding number of hexagons in the *y*-direction is chosen such that the hexagons are @@ -4171,7 +4171,7 @@ def hexbin(self, x, y, C=None, gridsize=100, bins=None, linewidths : scalar, optional, default is *None* If *None*, defaults to 1.0. - edgecolors : {'none'}, mpl color, optional, default is 'none' + edgecolors : {'none'} or mpl color, optional, default is 'none' If 'none', draws the edges in the same color as the fill color. This is the default, as it avoids unsightly unpainted pixels between the hexagons.