Histogram¶
1xNumeric¶
Using matplotlib¶
In [282]:
plt.figure(figsize=(10,3)) plt.subplot(1,2,1) plt.hist(mydf.value1); # default 10 bins plt.subplot(1,2,2) plt.hist(mydf.value1, bins=15);

Using Plotnine¶
plotnine.ggplot( dataframe, aex(x='colName')) + geom_histogram( bins=10 )
plotnine.ggplot( dataframe, aex(x='colName')) + geom_histogram( binwidth=? )
In [283]:
from plotnine import * plotnine.options.figure_size = (3, 3) ggplot(mydf, aes(x='value1')) + geom_histogram() # default bins = 10
--------------------------------------------------------------------------- NameError Traceback (most recent call last) <ipython-input-283-ef47ff619ba9> in <module>() 1 from plotnine import * ----> 2plotnine.options.figure_size = (3, 3) 3 ggplot(mydf, aes(x='value1')) + geom_histogram() # default bins = 10 NameError: name 'plotnine' is not defined
In [ ]:
ggplot(mydf, aes(x='value1')) + geom_histogram(bins = 15)
In [ ]:
ggplot(mydf, aes(x='value1')) + geom_histogram(binwidth = 3)
1xNumeric + 1xCategorical¶
plotnine.ggplot( dataframe,
aes(x='colName'),
fill='categorical-alike-colName')
+ geom_histogram()
In [284]:
ggplot(mydf, aes(x='value1', fill='grp')) + geom_histogram(bins=15)
Out[284]:
<ggplot: (189811487983)>