When I try to do a plot against a range with big enough numbers I get an axis with relative shift for all the ticks. For example:
plot([1000, 1001, 1002], [1, 2, 3])
I get these ticks on axis of abscissas:
0.0 0.5 1.0 1.5 2.0 +1e3
The question is how to remove +1e3
and get just:
1000.0 1000.5 1001.0 1001.5 1002.0
Matplotlib removes both labels and ticks by using xticks([]) and yticks([]) By using the method xticks() and yticks() you can disable the ticks and tick labels from both the x-axis and y-axis. In the above example, we use plt.
MatPlotLib with PythonSet the figure size and adjust the padding between and around the subplots. Create x and y data points using numpy. Plot the x and y data points for the original curve. Plot the shifted graph, in the range of (1, 1+len(y)) with y data points.
The plt. axis() method allows you to set the x and y limits with a single call, by passing a list which specifies [xmin, xmax, ymin, ymax] : In [11]: plt.
We can set the dpi value to get a high-quality image. Using the saving() method, we can save the image with format=”png” and dpi=1200. To show the image, use the plt. show() method.
plot([1000, 1001, 1002], [1, 2, 3]) gca().get_xaxis().get_major_formatter().set_useOffset(False) draw()
This grabs the current axes
, gets the x-axis axis
object and then the major formatter object and sets useOffset to false (doc).
In newer versions (1.4+) of matplotlib the default behavior can be changed via the axes.formatter.useoffset
rcparam.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With