2016-06-21 70 views
-1

plot of electric fieldplot of electron phase space distribution的Python:改變軸長度

我是新來的Python,我有這樣的腳本生成連接的故事情節,

fig = plt.figure(figsize=(9,3.0)) 
ax = fig.add_subplot(111) 
mul = 1e-2 * m0 * c * wpe/q0 
im = ax.pcolormesh(X,Y,dat.Electric_Field_Ex.data[sx,sy]/mul) 
plt.yticks(np.arange(np.min(Y), np.max(Y)+1, 2.0)) 
plt.xlabel("X-Position") 
plt.ylabel("Y-Position") 

divider = make_axes_locatable(ax) 
cax = divider.append_axes("right", size="5%", pad=0.2) 
cbar = plt.colorbar(im, cax=cax) 
cbar.set_ticks(np.arange(-1, 4, 1)) 
ax.set_xlim([-x0,x0]) 
[enter image description here][1]plt.savefig('ex.png',dpi=300,bbox_inches='tight') 

我要讓x軸不再如從-5到5?我該怎麼做呢?

任何幫助將不勝感激...謝謝

回答

2

只需設置XLIM爲-5〜5:

ax.set_xlim([-5,5]) 
+0

謝謝!我會嘗試 –

+0

它的工作表示感謝,我一直在看它很長時間,我看不到這種可怕!謝謝 –

+0

如果這對你有效,你應該[接受答案](http://stackoverflow.com/help/accepted-answer)讓其他人知道並將問題標記爲已解決。 – Scimonster