Removing Relative Shift in Matplotlib Axis
Plotting against large numbers in Matplotlib can result in an axis with a relative shift for the tick labels. To illustrate, consider the following plot:
plot([1000, 1001, 1002], [1, 2, 3])
This generates ticks on the abscissa axis as follows:
0.0 0.5 1.0 1.5 2.0 1e3
To eliminate the " 1e3" label and obtain tick labels of the form "1000.0", "1001.0", etc., follow these steps:
Alternatively, in newer versions of Matplotlib (1.4 ), the default behavior can be modified via the axes.formatter.useoffset rcparam:
matplotlib.rcParams['axes.formatter.useoffset'] = False
By applying these methods, you can remove the relative shift in the axis and obtain tick labels in the desired format.
Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.
Copyright© 2022 湘ICP备2022001581号-3