- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
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 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 −
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.
Example
# 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()
Output
It will produce the following output −
- Related Articles
- How to set the unit length of an axis in Matplotlib?
- How to set the font size of Matplotlib axis Legend?
- How to set my xlabel at the end of X-axis in Matplotlib?
- How to set X-axis values in Matplotlib Python?
- How to set axis ticks in multiples of pi in Python Matplotlib?
- How to set the range of Y-axis for a Seaborn boxplot using Matplotlib?
- How to change the range of the X-axis and Y-axis in Matplotlib?
- How to customize the X-axis in Matplotlib?
- How to set a multiplier to scale by in the URL string of IText object using FabricJS?
- FabricJS – How to set a multiplier to scale by in the URL string of a Line object?
- How to annotate a range of the X-axis in Matplotlib?
- How to draw axis in the middle of a figure in Matplotlib?
- How to set "step" on axis X in my figure in Matplotlib Python 2.6.6?
- How to set a multiplier to scale a cloned image using FabricJS?
- How to set the range of Y-axis in Python Plotly?

Advertisements