- Trending Categories
- Data Structure
- Operating System
- C Programming
- 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 to rotate xticklabels in Matplotlib so that the spacing between each xticklabel is equal?
63 Lectures 6 hours
To rotate xticklabels in matplotlib to make equal spacing between two xticklabels, we can take the following steps −
Make a list of numbers from 1 to 4.
Using subplot(), sdd a subplot to the current figure.
Add xticks and yticks on the current subplot (using step 1).
Set xtick labels by passing a list and to make label rotation (= 45).
To display the figure, use show() method.
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_yticks(x) ax1.set_xticklabels(["one", "two", "three", "four"], rotation=45) plt.show()
- How to change the spacing between ticks in Matplotlib?
- How to set the xticklabels for date in matplotlib?
- How to increase the spacing between subplots in Matplotlib with subplot2grid?
- Setting the spacing between grouped bar plots in Matplotlib
- Minimum flips in two binary arrays so that their XOR is equal to another array in C++.
- Program to balance the direction string so that each direction occurred quarter times in Python
- How to rotate a simple matplotlib Axes?
- Adjusting the spacing between the edge of the plot and the X-axis in Matplotlib
- How to rotate the rectangle patch in a plot using Matplotlib?
- Find unique pairs such that each element is less than or equal to N in C++
- How to rotate Matplotlib annotation to match a line?
- How to rotate tick labels in a subplot in Matplotlib?
- C++ program to find unique pairs such that each element is less than or equal to N
- Change the spacing of dashes in a dashed line in Matplotlib?