Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to turn off autoscaling in matplotlib.pyplot

I am using matplotlib.pyplot in python to plot my data. The problem is the image it generates seems to be autoscaled. How can I turn this off so that when I plot something at (0,0) it will be placed fixed in the center?

like image 612
overmind Avatar asked Jul 28 '16 07:07

overmind


People also ask

How do you change Figsize in Pyplot?

If you've already got the figure created, say it's 'figure 1' (that's the default one when you're using pyplot), you can use figure(num=1, figsize=(8, 6), ...) to change it's size etc.

What is the default Figsize Matplotlib?

figsize"] (default: [6.4, 4.8]) = [6.4, 4.8] . dpiinteger, optional, default: None. resolution of the figure. If not provided, defaults to rcParams["figure. dpi"] (default: 100.0) = 100 .


1 Answers

You want the autoscale function:

from matplotlib import pyplot as plt

# Set the limits of the plot
plt.xlim(-1, 1)
plt.ylim(-1, 1)

# Don't mess with the limits!
plt.autoscale(False)

# Plot anything you want
plt.plot([0, 1])
like image 89
Marijn van Vliet Avatar answered Oct 24 '22 08:10

Marijn van Vliet