From 0e602ce15ecde1bfc1f3e7cb462b745cb9f7b5fa Mon Sep 17 00:00:00 2001 From: Isaiah Akorita Date: Wed, 5 Mar 2025 15:05:28 +0100 Subject: [PATCH 1/6] add bivariate options --- hvplot/plotting/core.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/hvplot/plotting/core.py b/hvplot/plotting/core.py index 63f4c47bb..4dd0b4f81 100644 --- a/hvplot/plotting/core.py +++ b/hvplot/plotting/core.py @@ -930,7 +930,9 @@ def hexbin(self, x=None, y=None, C=None, colorbar=True, **kwds): """ return self(x, y, kind='hexbin', C=C, colorbar=colorbar, **kwds) - def bivariate(self, x=None, y=None, colorbar=True, **kwds): + def bivariate( + self, x=None, y=None, colorbar=True, bandwidth=None, cut=3, filled=False, levels=10, **kwds + ): """ A bivariate, density plot uses nested contours (or contours plus colors) to indicate regions of higher local density. @@ -951,9 +953,9 @@ def bivariate(self, x=None, y=None, colorbar=True, **kwds): bandwidth: int, optional The bandwidth of the kernel for the density estimate. Default is None. cut: Integer, Optional - Draw the estimate to cut * bw from the extreme data points. Default is None. + Draw the estimate to cut * bw from the extreme data points. Default is 3. filled : bool, optional - If True the the contours will be filled. Default is False. + If True the contours will be filled. Default is False. levels: int, optional The number of contour lines to draw. Default is 10. @@ -1000,7 +1002,17 @@ def bivariate(self, x=None, y=None, colorbar=True, **kwds): - Seaborn: https://seaborn.pydata.org/generated/seaborn.kdeplot.html - Wiki: https://en.wikipedia.org/wiki/Bivariate_analysis """ - return self(x, y, kind='bivariate', colorbar=colorbar, **kwds) + return self( + x, + y, + kind='bivariate', + colorbar=colorbar, + bandwidth=bandwidth, + cut=cut, + filled=filled, + levels=levels, + **kwds, + ) def bar(self, x=None, y=None, stacked=False, **kwds): """ From b953b3d815105976cf2e39754f18f1b4bd5c666e Mon Sep 17 00:00:00 2001 From: Isaiah Akorita Date: Wed, 5 Mar 2025 15:07:23 +0100 Subject: [PATCH 2/6] add contour options --- hvplot/plotting/core.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/hvplot/plotting/core.py b/hvplot/plotting/core.py index 4dd0b4f81..7d90d3f7a 100644 --- a/hvplot/plotting/core.py +++ b/hvplot/plotting/core.py @@ -2264,7 +2264,7 @@ def quadmesh(self, x=None, y=None, z=None, colorbar=True, **kwds): """ return self(x, y, z=z, kind='quadmesh', colorbar=colorbar, **kwds) - def contour(self, x=None, y=None, z=None, colorbar=True, **kwds): + def contour(self, x=None, y=None, z=None, colorbar=True, levels=5, logz=False, **kwds): """ Line contour plot @@ -2278,10 +2278,12 @@ def contour(self, x=None, y=None, z=None, colorbar=True, **kwds): The coordinate variable along the y-axis z : string, optional The data variable to plot - levels: int, optional - The number of contour levels colorbar: boolean Whether to display a colorbar + levels: int, optional + The number of contour levels. Default is 5 + logz: bool, optional + Whether to apply log scaling to the z-axis. Default is False **kwds : optional Additional keywords arguments are documented in `hvplot.help('contour')`. @@ -2325,9 +2327,9 @@ def contour(self, x=None, y=None, z=None, colorbar=True, **kwds): - Matplotlib: https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.contour.html - Plotly: https://plotly.com/python/contour-plots/ """ - return self(x, y, z=z, kind='contour', colorbar=colorbar, **kwds) + return self(x, y, z=z, kind='contour', colorbar=colorbar, levels=levels, logz=logz, **kwds) - def contourf(self, x=None, y=None, z=None, colorbar=True, **kwds): + def contourf(self, x=None, y=None, z=None, colorbar=True, levels=5, logz=False, **kwds): """ Filled contour plot @@ -2341,10 +2343,12 @@ def contourf(self, x=None, y=None, z=None, colorbar=True, **kwds): The coordinate variable along the y-axis z : string, optional The data variable to plot - levels: int, optional - The number of contour levels colorbar: boolean Whether to display a colorbar + levels: int, optional + The number of contour levels. default is 5 + logz: bool, optional + Whether to apply log scaling to the z-axis. Default is False **kwds : optional Additional keywords arguments are documented in `hvplot.help('contourf')`. @@ -2387,4 +2391,6 @@ def contourf(self, x=None, y=None, z=None, colorbar=True, **kwds): - Matplotlib: https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.contour.html - Plotly: https://plotly.com/python/contour-plots/ """ - return self(x, y, z=z, kind='contourf', colorbar=colorbar, **kwds) + return self( + x, y, z=z, kind='contourf', colorbar=colorbar, levels=levels, logz=logz, **kwds + ) From 71f69b49ee1f2ddba3ee3e52dab9ec371b9941a6 Mon Sep 17 00:00:00 2001 From: Isaiah Akorita Date: Wed, 5 Mar 2025 17:54:52 +0100 Subject: [PATCH 3/6] add heatmap options --- hvplot/plotting/core.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hvplot/plotting/core.py b/hvplot/plotting/core.py index 7d90d3f7a..e3af31241 100644 --- a/hvplot/plotting/core.py +++ b/hvplot/plotting/core.py @@ -799,7 +799,7 @@ def ohlc(self, x=None, y=None, **kwds): """ return self(kind='ohlc', x=x, y=y, **kwds) - def heatmap(self, x=None, y=None, C=None, colorbar=True, **kwds): + def heatmap(self, x=None, y=None, C=None, colorbar=True, logz=False, **kwds): """ `heatmap` visualises tabular data indexed by two key dimensions as a grid of colored values. This allows spotting correlations in multivariate data and provides a high-level overview @@ -822,6 +822,8 @@ def heatmap(self, x=None, y=None, C=None, colorbar=True, **kwds): Whether to apply log scaling to the z-axis. Default is False. reduce_function : function, optional Function to compute statistics for heatmap, for example `np.mean`. + If omitted, no aggregation is applied and duplicate values are dropped. + Note: Explicitly setting this parameter to `None` is not allowed and will raise an error. **kwds : optional Additional keywords arguments are documented in `hvplot.help('heatmap')`. @@ -860,7 +862,7 @@ def heatmap(self, x=None, y=None, C=None, colorbar=True, **kwds): - Plotly: https://plotly.com/python/heatmaps/ - Wiki: https://en.wikipedia.org/wiki/Heat_map """ - return self(x, y, kind='heatmap', C=C, colorbar=colorbar, **kwds) + return self(x, y, kind='heatmap', C=C, colorbar=colorbar, logz=logz, **kwds) def hexbin(self, x=None, y=None, C=None, colorbar=True, **kwds): """ From dfb13bfb7728a78714fe47e80c8207cede7a5387 Mon Sep 17 00:00:00 2001 From: Isaiah Akorita Date: Wed, 12 Mar 2025 17:20:50 +0100 Subject: [PATCH 4/6] add hexbin options --- hvplot/plotting/core.py | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/hvplot/plotting/core.py b/hvplot/plotting/core.py index e3af31241..08b1ee3a2 100644 --- a/hvplot/plotting/core.py +++ b/hvplot/plotting/core.py @@ -823,7 +823,7 @@ def heatmap(self, x=None, y=None, C=None, colorbar=True, logz=False, **kwds): reduce_function : function, optional Function to compute statistics for heatmap, for example `np.mean`. If omitted, no aggregation is applied and duplicate values are dropped. - Note: Explicitly setting this parameter to `None` is not allowed and will raise an error. + Note: Explicitly setting this parameter to `None` is not allowed and will raise a TypeError. **kwds : optional Additional keywords arguments are documented in `hvplot.help('heatmap')`. @@ -864,7 +864,9 @@ def heatmap(self, x=None, y=None, C=None, colorbar=True, logz=False, **kwds): """ return self(x, y, kind='heatmap', C=C, colorbar=colorbar, logz=logz, **kwds) - def hexbin(self, x=None, y=None, C=None, colorbar=True, **kwds): + def hexbin( + self, x=None, y=None, C=None, colorbar=True, gridsize=50, logz=False, min_count=1, **kwds + ): """ The `hexbin` plot uses hexagons to split the area into several parts and attribute a color to it. @@ -885,8 +887,10 @@ def hexbin(self, x=None, y=None, C=None, colorbar=True, **kwds): Whether to display a colorbar. Default is True. reduce_function : function, optional Function to compute statistics for hexbins, for example `np.mean`. + Default aggregation is a count of the values in the area. + Note: Explicitly setting this parameter to `None` is not allowed and will raise a TypeError. gridsize: int, optional - The number of hexagons in the x-direction + The number of hexagons in the x-direction. Default is 50. logz : bool Whether to apply log scaling to the z-axis. Default is False. min_count : number, optional @@ -930,7 +934,17 @@ def hexbin(self, x=None, y=None, C=None, colorbar=True, **kwds): - Plotly: https://plotly.com/python/hexbin-mapbox/ - Wiki: https://think.design/services/data-visualization-data-design/hexbin/ """ - return self(x, y, kind='hexbin', C=C, colorbar=colorbar, **kwds) + return self( + x, + y, + kind='hexbin', + C=C, + colorbar=colorbar, + gridsize=gridsize, + logz=logz, + min_count=min_count, + **kwds, + ) def bivariate( self, x=None, y=None, colorbar=True, bandwidth=None, cut=3, filled=False, levels=10, **kwds From aa6e6d1620464d9c1040257f9cdcde02795b4951 Mon Sep 17 00:00:00 2001 From: Isaiah Akorita Date: Mon, 17 Mar 2025 19:38:41 +0100 Subject: [PATCH 5/6] update hist options --- hvplot/plotting/core.py | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/hvplot/plotting/core.py b/hvplot/plotting/core.py index 08b1ee3a2..14d911905 100644 --- a/hvplot/plotting/core.py +++ b/hvplot/plotting/core.py @@ -1317,7 +1317,7 @@ def violin(self, y=None, by=None, **kwds): """ return self(kind='violin', x=None, y=y, by=by, **dict(kwds, hover=False)) - def hist(self, y=None, by=None, **kwds): + def hist(self, y=None, by=None, bins=20, normed=False, cumulative=False, **kwds): """ A `histogram` displays an approximate representation of the distribution of continuous data. @@ -1331,17 +1331,24 @@ def hist(self, y=None, by=None, **kwds): by : string or sequence Field(s) in the *long* data to group by. bins : int, optional - The number of bins + An explicit set of bin edges or a method to find the optimal + set of bin edges, e.g. 'auto', 'fd', 'scott' etc. For more + documentation on these approaches see the np.histogram_bin_edges + documentation. Default is 20 bin_range: tuple, optional - The lower and upper range of the bins. Default is None. + The lower and upper range of the bins. + Default is the minimum and maximum values of the continuous data. normed : bool, optional - If True the distribution will sum to 1. Default is False. + Controls normalization behavior. If `True` or `'integral'`, then + `density=True` is passed to np.histogram, and the distribution + is normalized such that the integral is unity. If `False`, + then the frequencies will be raw counts. If `'height'`, then the + frequencies are normalized such that the max bin height is unity. + Default is False. cumulative: bool, optional If True, then a histogram is computed where each bin gives the counts in that bin plus all bins for smaller values. The last bin gives the total number of datapoints. Default is False. - alpha : float, optional - An alpha value between 0.0 and 1.0 to better visualize multiple fields. Default is 1.0. kwds : optional Additional keywords arguments are documented in `hvplot.help('hist')`. @@ -1396,7 +1403,16 @@ def hist(self, y=None, by=None, **kwds): - Seaborn: https://seaborn.pydata.org/generated/seaborn.histplot.html - Wiki: https://en.wikipedia.org/wiki/Histogram """ - return self(kind='hist', x=None, y=y, by=by, **kwds) + return self( + kind='hist', + x=None, + y=y, + by=by, + bins=bins, + normed=normed, + cumulative=cumulative, + **kwds, + ) def kde(self, y=None, by=None, **kwds): """ From b6b275190d5dfbca8d0fb383f1626aa22e703ba2 Mon Sep 17 00:00:00 2001 From: maximlt Date: Mon, 17 Mar 2025 20:19:33 +0100 Subject: [PATCH 6/6] minor changes --- hvplot/plotting/core.py | 64 +++++++++++++++++++++++++---------------- 1 file changed, 39 insertions(+), 25 deletions(-) diff --git a/hvplot/plotting/core.py b/hvplot/plotting/core.py index 14d911905..1cbf585a9 100644 --- a/hvplot/plotting/core.py +++ b/hvplot/plotting/core.py @@ -823,7 +823,6 @@ def heatmap(self, x=None, y=None, C=None, colorbar=True, logz=False, **kwds): reduce_function : function, optional Function to compute statistics for heatmap, for example `np.mean`. If omitted, no aggregation is applied and duplicate values are dropped. - Note: Explicitly setting this parameter to `None` is not allowed and will raise a TypeError. **kwds : optional Additional keywords arguments are documented in `hvplot.help('heatmap')`. @@ -865,7 +864,15 @@ def heatmap(self, x=None, y=None, C=None, colorbar=True, logz=False, **kwds): return self(x, y, kind='heatmap', C=C, colorbar=colorbar, logz=logz, **kwds) def hexbin( - self, x=None, y=None, C=None, colorbar=True, gridsize=50, logz=False, min_count=1, **kwds + self, + x=None, + y=None, + C=None, + colorbar=True, + gridsize=50, + logz=False, + min_count=None, + **kwds, ): """ The `hexbin` plot uses hexagons to split the area into several parts and attribute a color @@ -888,9 +895,11 @@ def hexbin( reduce_function : function, optional Function to compute statistics for hexbins, for example `np.mean`. Default aggregation is a count of the values in the area. - Note: Explicitly setting this parameter to `None` is not allowed and will raise a TypeError. - gridsize: int, optional - The number of hexagons in the x-direction. Default is 50. + gridsize: int or tuple, optional + Number of hexagonal bins along x- and y-axes. Defaults to uniform + sampling along both axes when setting and integer but independent + bin sampling can be specified a tuple of integers corresponding to + the number of bins along each axis. Default is 50. logz : bool Whether to apply log scaling to the z-axis. Default is False. min_count : number, optional @@ -968,12 +977,13 @@ def bivariate( Whether to display a colorbar bandwidth: int, optional The bandwidth of the kernel for the density estimate. Default is None. - cut: Integer, Optional + cut: int, optional Draw the estimate to cut * bw from the extreme data points. Default is 3. filled : bool, optional If True the contours will be filled. Default is False. - levels: int, optional - The number of contour lines to draw. Default is 10. + levels: int or list, optional + The number of contour lines to draw or a list of scalar values used + to specify the contour levels. Default is 10. **kwds : optional Additional keywords arguments are documented in `hvplot.help('bivariate')`. @@ -1317,7 +1327,9 @@ def violin(self, y=None, by=None, **kwds): """ return self(kind='violin', x=None, y=y, by=by, **dict(kwds, hover=False)) - def hist(self, y=None, by=None, bins=20, normed=False, cumulative=False, **kwds): + def hist( + self, y=None, by=None, bins=20, bin_range=None, normed=False, cumulative=False, **kwds + ): """ A `histogram` displays an approximate representation of the distribution of continuous data. @@ -1330,25 +1342,25 @@ def hist(self, y=None, by=None, bins=20, normed=False, cumulative=False, **kwds) Please note the fields should contain continuous data. Not categorical. by : string or sequence Field(s) in the *long* data to group by. - bins : int, optional - An explicit set of bin edges or a method to find the optimal - set of bin edges, e.g. 'auto', 'fd', 'scott' etc. For more - documentation on these approaches see the np.histogram_bin_edges - documentation. Default is 20 + bins : int or string or np.ndarray or list or tuple, optional + The number of bins in the histogram, or an explicit set of bin edges + or a method to find the optimal set of bin edges, e.g. 'auto', 'fd', + 'scott' etc. For more documentation on these approaches see the + :class:`numpy:numpy.histogram_bin_edges` documentation. Default is 20. bin_range: tuple, optional The lower and upper range of the bins. Default is the minimum and maximum values of the continuous data. - normed : bool, optional - Controls normalization behavior. If `True` or `'integral'`, then - `density=True` is passed to np.histogram, and the distribution - is normalized such that the integral is unity. If `False`, - then the frequencies will be raw counts. If `'height'`, then the + normed : str or bool, optional + Controls normalization behavior. If ``True`` or ``'integral'``, then + ``density=True`` is passed to np.histogram, and the distribution + is normalized such that the integral is unity. If ``False``, + then the frequencies will be raw counts. If ``'height'``, then the frequencies are normalized such that the max bin height is unity. Default is False. cumulative: bool, optional - If True, then a histogram is computed where each bin gives the counts in that bin plus - all bins for smaller values. The last bin gives the total number of datapoints. - Default is False. + If True, then a histogram is computed where each bin gives the counts + in that bin plus all bins for smaller values. The last bin gives the + total number of data points. Default is False. kwds : optional Additional keywords arguments are documented in `hvplot.help('hist')`. @@ -2312,8 +2324,9 @@ def contour(self, x=None, y=None, z=None, colorbar=True, levels=5, logz=False, * The data variable to plot colorbar: boolean Whether to display a colorbar - levels: int, optional - The number of contour levels. Default is 5 + levels: int or list, optional + The number of contour lines to draw or a list of scalar values used + to specify the contour levels. Default is 5 logz: bool, optional Whether to apply log scaling to the z-axis. Default is False **kwds : optional @@ -2378,7 +2391,8 @@ def contourf(self, x=None, y=None, z=None, colorbar=True, levels=5, logz=False, colorbar: boolean Whether to display a colorbar levels: int, optional - The number of contour levels. default is 5 + The number of contour lines to draw or a list of scalar values used + to specify the contour levels. Default is 5 logz: bool, optional Whether to apply log scaling to the z-axis. Default is False **kwds : optional