Skip to content

Complete the signature of plot methods with all their kind options #1523

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Mar 18, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
132 changes: 98 additions & 34 deletions hvplot/plotting/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason why reduce_function hasn't been added to the signature?

"""
`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
Expand All @@ -822,6 +822,7 @@ 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.
**kwds : optional
Additional keywords arguments are documented in `hvplot.help('heatmap')`.

Expand Down Expand Up @@ -860,9 +861,19 @@ 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)

def hexbin(self, x=None, y=None, C=None, colorbar=True, **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=None,
**kwds,
):
"""
The `hexbin` plot uses hexagons to split the area into several parts and attribute a color
to it.
Expand All @@ -883,8 +894,12 @@ 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`.
gridsize: int, optional
The number of hexagons in the x-direction
Default aggregation is a count of the values in the area.
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
Expand Down Expand Up @@ -928,9 +943,21 @@ 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, **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.
Expand All @@ -950,12 +977,13 @@ def bivariate(self, x=None, y=None, colorbar=True, **kwds):
Whether to display a colorbar
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.
cut: int, optional
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.
levels: int, optional
The number of contour lines to draw. Default is 10.
If True the contours will be filled. Default is False.
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')`.
Expand Down Expand Up @@ -1000,7 +1028,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):
"""
Expand Down Expand Up @@ -1289,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, **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.

Expand All @@ -1302,18 +1342,25 @@ def hist(self, y=None, by=None, **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
The number of bins
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 None.
normed : bool, optional
If True the distribution will sum to 1. 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.
The lower and upper range of the bins.
Default is the minimum and maximum values of the continuous data.
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.
alpha : float, optional
An alpha value between 0.0 and 1.0 to better visualize multiple fields. Default is 1.0.
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 data points. Default is False.
kwds : optional
Additional keywords arguments are documented in `hvplot.help('hist')`.

Expand Down Expand Up @@ -1368,7 +1415,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):
"""
Expand Down Expand Up @@ -2252,7 +2308,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

Expand All @@ -2266,10 +2322,13 @@ 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 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
Additional keywords arguments are documented in `hvplot.help('contour')`.

Expand Down Expand Up @@ -2313,9 +2372,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

Expand All @@ -2329,10 +2388,13 @@ 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 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
Additional keywords arguments are documented in `hvplot.help('contourf')`.

Expand Down Expand Up @@ -2375,4 +2437,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
)
Loading