- 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 change the spacing between ticks in Matplotlib?
To set ticks on a fixed position or change the spacing between ticks in matplotlib, we can take the following steps −
Create a figure and add a set of subplots.
To set the ticks on a fixed position, create two lists with some values.
Use set_yticks and set_xticks methods to set the ticks on the axes.
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 fig, ax = plt.subplots() xtick_loc = [0.20, 0.75, 0.30] ytick_loc = [0.12, 0.80, 0.76] ax.set_xticks(xtick_loc) ax.set_yticks(ytick_loc) plt.show()
- How to change the color of the ticks in the colorbar in Matplotlib?
- How to increase the spacing between subplots in Matplotlib with subplot2grid?
- Change the spacing of dashes in a dashed line in Matplotlib?
- Setting the spacing between grouped bar plots in Matplotlib
- How to add Matplotlib Colorbar Ticks?
- How to change the color of the axis, ticks and labels for a plot in matplotlib?
- How can I change the font size of ticks of axes object in Matplotlib?
- How to customize X-axis ticks in Matplotlib?
- How to rotate xticklabels in Matplotlib so that the spacing between each xticklabel is equal?
- How to change the axis ticks color in base R plot?
- How to set the number of ticks in plt.colorbar in Matplotlib?
- How to set the ticks on a Fixed Position in Matplotlib?
- Adjusting the spacing between the edge of the plot and the X-axis in Matplotlib
- How to disable the minor ticks of a log-plot in Matplotlib?
- How to add third level of ticks in Python Matplotlib?