- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How can I rotate xtick labels through 90 degrees in Matplotlib?
To rotate xtick labels through 90 degrees, we can take the following steps −
Make a list (x) of numbers.
Add a subplot to the current figure.
Set ticks on X-axis.
Set xtick labels and use rotate=90 as the arguments in the method.
To display the figure, use show() method.
Example
import matplotlib.pyplot as plt plt.rcParams["figure.figsize"] = [7.00, 3.50] plt.rcParams["figure.autolayout"] = True x = [1, 2, 3, 4] ax1 = plt.subplot() ax1.set_xticks(x) ax1.set_xticklabels(["one", "two", "three", "four"], rotation=90) plt.show()
Output
- Related Articles
- Rotate xtick labels in Seaborn boxplot using Matplotlib
- How can I make the xtick labels of a plot be simple drawings using Matplotlib?
- How to put xtick labels in a box matplotlib?
- How can I draw inline line labels in Matplotlib?
- How to rotate tick labels in a subplot in Matplotlib?
- Program to rotate square matrix by 90 degrees counterclockwise in Python
- How can I cycle through line styles in Matplotlib?
- Write a program in Java to rotate a matrix by 90 degrees in anticlockwise direction
- Rotate div to -20 degrees angle with CSS
- Rotate tick labels for Seaborn barplot in Matplotib
- How do I customize the display of edge labels using networkx in Matplotlib?
- How to rotate X-axis tick labels in Pandas bar plot?
- How to rotate a simple matplotlib Axes?
- How to change the separation between tick labels and axis labels in Matplotlib?
- How can I show figures separately in Matplotlib?

Advertisements