How can Seaborn library be used to display Histograms in Python?

PythonServer Side ProgrammingProgramming

Visualizing data is an important step since it helps understand what is going on in the data without actually looking at the numbers and performing complicated computations. It helps in communicating the quantitative insights to the audience effectively.

Seaborn is a library that helps in visualizing data. It comes with customized themes and a high-level interface.

Let us see an example to display Histograms in Python −

Example

import pandas as pd
import seaborn as sb
from matplotlib import pyplot as plt
df = sb.load_dataset('iris')
sb.distplot(df['petal_length'],kde = False)
plt.show()

Output

Explanation

  • The required packages are imported.
  • The input data is ‘iris_data’ which is loaded from the scikit learn library.
  • The ‘load_dataset’ function is used to load the iris data.
  • This data is visualized using the ‘distplot’ function.
  • Here, the parameter ‘kde’ is set to false since we only want to display the histogram.
  • This visual data is displayed on the console.
raja
Published on 10-Dec-2020 13:04:21
Advertisements