- 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 set the value of the axis multiplier in matplotlib?
To set the value of the axis multiplier in matplotlib, we can take the following steps −
Set the figure size and adjust the padding between and around the subplots.
Create x data points using numpy.
Plot x and x2 using plot() method.
Get the current axis of the figure.
Initialize a variable multiplier, i.e., a value of the axis multiplier.
Set a tick on each integer multiple of a base within the view interval.
Set the locator of the major ticker.
To display the figure, use show() method.
# Import matplotlib and numpy from matplotlib import pyplot as plt import numpy as np # Set the figure size plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True # Create x data points x = np.linspace(1, 100, 100) # Plot x and x2 plt.plot(x, x**2) # Get the current axis ax = plt.gca() # Axis multiplier multiplier = 6 # Set a tick on each integer multiple locator = plt.MultipleLocator(multiplier) # Set the locator of the major ticker ax.xaxis.set_major_locator(locator) plt.show()
It will produce the following output −
- How to set the font size of Matplotlib axis Legend?
- How to set the unit length of an axis in Matplotlib?
- How to set my xlabel at the end of X-axis in Matplotlib?
- How to change the range of the X-axis and Y-axis in Matplotlib?
- How to set the range of Y-axis for a Seaborn boxplot using Matplotlib?
- How to set X-axis values in Matplotlib Python?
- How to customize the X-axis in Matplotlib?
- How to set axis ticks in multiples of pi in Python Matplotlib?
- How to annotate a range of the X-axis in Matplotlib?
- Changing the color of an axis in Matplotlib
- How to draw axis in the middle of a figure in Matplotlib?
- How to exponentially scale the Y axis with matplotlib?
- How to set the margins of a Matplotlib figure?
- Changing the formatting of a datetime axis in Matplotlib
- How to set the alignment of the JLabel content along the X axis in Java?