LA ILAHA ILLA HU
Allah, Your Lord There Is No Deity Except Him.
Python Data Science Matplotlib Numpy Random Seaborn sns.distplot
Visualizing Random Data Distributions With Seaborn
Seaborn is a library which is used to visualize random data distributions, Seaborn uses Matplotlib underneath to plot graphs.
Example 1: Plotting a distplot random data distribution plot with seaborn.
Code
import matplotlib.pyplot as plt
import seaborn as sns
sns.distplot([0, 1, 2, 3, 4, 5, 6, 7])
plt.show()
the output will be
Installing Seaborn
If you have Python and PIP already installed on a system, install it using the command below.
C:\Users\Your Name>pip install seaborn
If you use Jupyter, install Seaborn using the command below.
C:\Users\Your Name>!pip install seaborn
Plotting A Distplots: Distplot stands for data distribution plot, it takes as input an array
and plots a curve corresponding to the distribution of points in the array.
Import Matplotlib
Import the pyplot object of the Matplotlib module in your code using the following statement.
import matplotlib.pyplot as plt
Import Seaborn
Import the Seaborn module in your code using the following statement.
import seaborn as sns
Plot a Distribution Plot
Example 2: Plotting a distplot with seaborn.
Code
import matplotlib.pyplot as plt
import seaborn as sns
sns.distplot([0, 1, 2, 3, 4, 5, 6, 7])
plt.show()
the output will be
Plotting a Distplot data distribution plot Without the Histogram
Example 3:plot a distplot without histogram.
Code
import matplotlib.pyplot as plt
import seaborn as sns
sns.distplot([0, 1, 2, 3, 4, 5, 6, 7], hist=False)
plt.show()
the output will be
Note: We have used: sns.distplot(arr, hist=False) to visualize random data distributions.