2016-07-28 14 views
2

私はPythonでmatplotlib.pyplotを使用してデータをプロットしています。問題は、それが生成するイメージが自動スケールされているように見えることです。どうすれば(0,0)で何かをプロットすると、それが中心に固定されるようにすることができますか?matplotlib.pyplotでオートスケーリングをオフにする方法

+0

が重複する可能性を[matplotlibのy軸の制限を設定する](http://stackoverflow.com/questions/3777861/setting-y-axis-limit-in-matplotlib) – SiHa

+0

これはありません。これはオートスケーリングについてです。 –

答えて

0

xlim()ylim()を使用して制限を設定できます。あなたのデータから行く、Yに30にX -50に-10〜20を言う知っていれば、行うことができます:

plt.xlim((-20, 20)) 
plt.ylim((-50, 50)) 

を0,0を中心にします。

データが動的である場合は、最初にオートスケールを許可しようとしたが、その後包括的であることを制限を設定できます。

xlim = plt.xlim() 
max_xlim = max(map(abs, xlim)) 
plt.xlim((-max_xlim, max_xlim)) 
ylim = plt.ylim() 
max_ylim = max(map(abs, ylim)) 
plt.ylim((-max_ylim, max_ylim)) 
4

あなたはautoscale機能します:の

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]) 
関連する問題