hvPlot.hist#

hvPlot.hist(y=None, by=None, bins=20, bin_range=None, normed=False, cumulative=False, **kwds)[source]#

A histogram displays an approximate representation of the distribution of continuous data.

Reference: https://hvplot.holoviz.org/reference/tabular/hist.html

Parameters:
ystring or sequence

Field(s) in the wide data to compute the distribution(s) from. Please note the fields should contain continuous data. Not categorical.

bystring or sequence

Field(s) in the long data to group by.

binsint 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 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.

normedstr 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 data points. Default is False.

kwdsoptional

Additional keywords arguments are documented in hvplot.help(‘hist’). See Plotting Options for more information.

Returns:
holoviews.element.Histogram / Panel object

You can print the object to study its composition and run:

import holoviews as hv
hv.help(the_holoviews_object)

to learn more about its parameters and options.

References

Examples

Lets display some wide data created by rolling two dices

import hvplot.pandas
import numpy as np
import pandas as pd

df = pd.DataFrame(np.random.randint(1, 7, 6000), columns = ['one'])
df['two'] = df['one'] + np.random.randint(1, 7, 6000)
df.hvplot.hist(bins=12, alpha=0.5, color=["lightgreen", "pink"])

If you want to show the distribution of the values of a categorical column, you can use Pandas’ method value_counts and bar as shown below

import hvplot.pandas
import pandas as pd

data = pd.DataFrame({
    "library": ["bokeh", "plotly", "matplotlib", "bokeh", "matplotlib", "matplotlib"]
})

data["library"].value_counts().hvplot.bar()

Backend-specific styling options#

alpha, cmap, color, fill_alpha, fill_color, hover_alpha, hover_color, hover_fill_alpha, hover_fill_color, hover_line_alpha, hover_line_cap, hover_line_color, hover_line_dash, hover_line_dash_offset, hover_line_join, hover_line_width, line_alpha, line_cap, line_color, line_dash, line_dash_offset, line_join, line_width, muted, muted_alpha, muted_color, muted_fill_alpha, muted_fill_color, muted_line_alpha, muted_line_cap, muted_line_color, muted_line_dash, muted_line_dash_offset, muted_line_join, muted_line_width, nonselection_alpha, nonselection_color, nonselection_fill_alpha, nonselection_fill_color, nonselection_line_alpha, nonselection_line_cap, nonselection_line_color, nonselection_line_dash, nonselection_line_dash_offset, nonselection_line_join, nonselection_line_width, selection_alpha, selection_color, selection_fill_alpha, selection_fill_color, selection_line_alpha, selection_line_cap, selection_line_color, selection_line_dash, selection_line_dash_offset, selection_line_join, selection_line_width, visible

align, alpha, c, capsize, color, ec, ecolor, edgecolor, error_kw, facecolor, fc, hatch, linewidth, log, lw, visible

Examples#

TBD

This web page was generated from a Jupyter notebook and not all interactivity will work on this website.