#20 Basic histogram | Seaborn

With Seaborn, histograms are made using the distplot function. You can call the function with default values (left), what already gives a nice chart. Do not forget to play with the number of bins using the ‘bins’ argument. It is important to do so: a pattern can be hidden under a bar. Here is the code:

# Import library and dataset
import seaborn as sns
df = sns.load_dataset('iris')

# Make default histogram of sepal length
sns.distplot( df["sepal_length"] )
#sns.plt.show()

# Control the number of bins
sns.distplot( df["sepal_length"], bins=20 )
#sns.plt.show()

 

Leave a Reply

Your email address will not be published.