#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"] )

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


  • Sponsors


    Leave a Reply to Geofrey Garsuta Cancel reply

    Your email address will not be published.