2012-07-12 14 views
17

:matplotlib'de, set_xlim ve set_xbound arasındaki fark nedir? yardım itibaren

set_xlim: Xaxis için ayarlayın veri sınırlar.

set_xbound: X ekseninin alt ve üst sayısal sınırlarını ayarlayın.

çok net değil

, o yüzden bir şey çizmek varsayalım: Şimdi

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

, Ya benim yaptığım:

ax.set_xlim(2, 7) 

ya:

ax.set_xbound(2, 7) 

ben farkı görmüyorum. Çizgiyi sürükleyebilirim, tüm satır 0 ile 9 arasına yerleştirilir.

+0

[Axes.set_xbound] (http://matplotlib.sourceforge.net/api/axes_api.html#matplotlib.axes.Axes.set_xbound) ([Axes.set_xlim] kullanır http://matplotlib.sourceforge.net/api/axes_api.html#matplotlib.axes.Axes.set_xlim) [code] 'a bir göz atın (https://github.com/matplotlib/matplotlib/blob/master/lib /matplotlib/axes.py#L2355) – adchilds

cevap

15

Daha sonra, ciltte olmayan bir şeyi çizerseniz, otomatik olarak değişir. Aksine, limitler sabittir ve otomatik olarak değişmez.

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

Tamam, bir sınırın üstesinden gelebilirsin, ancak bir sınırı aşamazsın? :-) Teşekkür ederim. – PhML

İlgili konular