2012-07-12 17 views
17

ヘルプから:matplotlibでは、set_xlimとset_xboundの違いは何ですか?

set_xlim: xaxisのデータ制限を設定します。

set_xbound: x軸の下限と上限の数値境界を設定します。

非常に明確ではありません、それでは、私が何かプロットとしましょう:今すぐ

import matplotlib.pylab as plt 
fig, ax = plt.subplots(1, 1) 
ax.plot(xrange(10), xrange(10)) 

を、どちらか私は:

ax.set_xlim(2, 7) 

か:

ax.set_xbound(2, 7) 

私は違いを見ないでください。私はプロットをドラッグすることができます、すべての行は0と9の間に表示されます。

+0

[Axes.set_xbound(http://matplotlib.sourceforge.net/api/axes_api.html#matplotlib.axes.Axes.set_xbound)は([Axes.set_xlim]使用しますhttp://matplotlib.sourceforge.net/api/axes_api.html#matplotlib.axes.Axes.set_xlim)[code](https://github.com/matplotlib/matplotlib/blob/master/lib)を見てください。 /matplotlib/axes.py#L2355) – adchilds

答えて

15

後でバインド内にないものをプロットすると、自動的にバインドが変更されます。対照的に、制限は固定されており、自動的には変更されません。

import pylab as p 

t = p.arange(0.0, 2.0, 0.01) 
s = p.sin(2*p.pi*t) 

ax=p.subplot(111) 
ax.plot(t, s, color='r',linewidth=1.0) 
ax.set_ylim(-1,1) 
ax.plot(t, s+1, color='g',linewidth=1.0, label="Graph2") 
p.show() 


ax=p.subplot(111) 
ax.plot(t, s, color='r',linewidth=1.0) 
ax.set_ybound(-1,1) 
ax.plot(t, s+1, color='g',linewidth=1.0, label="Graph2") 
p.show() 

enter image description here

enter image description here
+0

あなたは境界線を越えることができますが、限界はありませんか? :-) ありがとうございます。 – PhML

関連する問題