How to rotate x labels in Seaborn

You can rotate the x labels in Seaborn with the following code. In this article, you’ll see an example with a solution. The example helps you to understand how to rotate x labels in Seaborn. I highly recommend you “Python Crash Course Book” to learn Python.

Example: Rotate x labels 45 Degree in Seaborn

# Import the Seaborn library as sns
import seaborn as sns

# Load the iris Dataset
iris = sns.load_dataset("iris")

# Barplot
a = sns.barplot(x="species", y="petal_width", data=iris)

# Rotate the x labels 45 degree
a.tick_params(axis='x', rotation=45)

Output:

Leave a Comment

Your email address will not be published.