import hvplot.pandas # noqa
# hvplot.extension("matplotlib")
hist
is often a good way to start looking at continous data to get a sense of the distribution. Similar methods include kde
(also available as density
).
from bokeh.sampledata.autompg import autompg_clean
autompg_clean.sample(n=5)
autompg_clean.hvplot.hist("weight")
When using by
the plots are overlaid by default. To create subplots instead, use subplots=True
.
autompg_clean.hvplot.hist("weight", by="origin", subplots=True, width=250)
You can also plot histograms of datetime data
import pandas as pd
from bokeh.sampledata.commits import data as commits
commits = commits.reset_index().sort_values("datetime")
commits.head(3)
commits.hvplot.hist(
"datetime",
bin_range=(pd.Timestamp('2012-11-30'), pd.Timestamp('2017-05-01')),
bins=54,
)
If you want to plot the distribution of a categorical column you can calculate the distribution using Pandas' method value_counts
and plot it using .hvplot.bar
.
autompg_clean["mfr"].value_counts().hvplot.bar(invert=True, flip_yaxis=True, height=500)