python - How can I plot a discrete probability distribution with Seaborn? -


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.') 

dataframe

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:

a <code>pandas</code> bar plot

another option using seaborn:

sns.barplot(data = df,x='val.',y='freq.') 

<code>seaborn</code> bar plot


Comments