How to change font size in seaborn

You can change the font size in Seaborn with the following code. The given example helps you to understand how to change the font size of the Seaborn plot. I highly recommend you “Python Crash Course Book” to learn Python.

Example: Change Font Size

# Import the required libraries
import seaborn as sns
import matplotlib.pyplot as plt

# Create Data
dataset = [2,2,2,2,6,6,6,9,9] 

# Create Histogram
plot = sns.histplot(data = dataset)

# X-Label
plot.set_xlabel("Numbers", fontsize = 15)

# Y-Label
plot.set_ylabel("Frequency", fontsize = 15)

# Title
plot.set_title("Histogram", fontsize = 20)

# Legend             
plt.legend(labels=["Legend"], fontsize = 15)

# Display the plot
plt.show()

Output:

Leave a Comment

Your email address will not be published.