We can use the seaborn.displot() function to plot a distribution plot in the seaborn Python library. Let’s say we want to see the distribution of the age of passengers from the titanic dataset. To do so, we can use the following Python code:
import seaborn from matplotlib import pyplot df = seaborn.load_dataset("titanic") seaborn.displot(data=df, x="age", kind="hist") pyplot.savefig("seaborn-hist.png") pyplot.close()
Please note that here we are using a histogram as the underlying plotting function. The output histogram will look like the following:
But we can also use kde as the underlying plotting function. In that case, we will get a KDE or Kernel Density Estimate plot. We can use the following Python code to plot a KDE plot using the seaborn Python library:






0 Comments