i want plot discrete probability distribution (a mwe below).
in order keep graphics consistent, i'd use seaborn
.
from pandas import dataframe x = [2,3,5] freq = [0.3,0.2,0.5] df = dataframe({'val.':x,'freq.':freq}) df.set_index('val.')
is there way produce barplot of distribution (other generating data have distribution)?
one option use built-in dataframe plotting functions:
import pandas pd import seaborn sns x = [2,3,5] freq = [0.3,0.2,0.5] df = pd.dataframe({'val.':x,'freq.':freq}) df.set_index('val.')['freq.'].plot.bar(rot=0)
which produces:
another option using seaborn
:
sns.barplot(data = df,x='val.',y='freq.')
Comments
Post a Comment