VOOZH about

URL: https://www.geeksforgeeks.org/python/rotate-axis-tick-labels-in-seaborn-and-matplotlib/

⇱ Rotate axis tick labels in Seaborn and Matplotlib - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Rotate axis tick labels in Seaborn and Matplotlib

Last Updated : 23 Jul, 2025

Seaborn and Matplotlib both are commonly used libraries for data visualization in Python.  We can draw various types of plots using Matplotlib like scatter, line, bar, histogram, and many more. On the other hand, Seaborn provides a variety of visualization patterns. It uses easy syntax and has easily interesting default themes. It specializes in statistics visualization.

Creating a basic plot in Matplotlib

Output:

👁 Image

Creating basic plot in Seaborn

Output:

👁 Image

While plotting these plots one problem arises -the overlapping of x labels or y labels which causes difficulty to read what is on x-label and what is on y-label. So we solve this problem by Rotating x-axis labels or y-axis labels.

Rotating X-axis Labels in Matplotlib

We use plt.xticks(rotation=#) where # can be any angle by which we want to rotate the x labels

Output:

👁 Image

Rotating X-axis Labels in Seaborn

By using FacetGrid we assign barplot to variable 'g' and then we call the function set_xticklabels(labels=#list of labels on x-axis, rotation=*) where * can be any angle by which we want to rotate the x labels

Output:

👁 Image

Rotating Y-axis Labels in Matplotlib

We use plt.xticks(rotation=#) where # can be any angle by which we want to rotate the y labels

Output:

👁 Image

Rotating Y-axis Labels in Seaborn

By using FacetGrid we assign barplot to variable 'g' and then we call the function set_yticklabels(labels=#the scale we want for y label, rotation=*) where * can be any angle by which we want to rotate the y labels

Output:

👁 Image
Comment