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.
The above is the detailed content of How to Eliminate Relative Shift in Matplotlib\'s Tick Labels for Large Numbers?. For more information, please follow other related articles on the PHP Chinese website!