【问题标题】:Python: changing axes length [duplicate]Python:改变轴长度
【发布时间】:2016-10-23 03:58:33
【问题描述】:

plot of electric fieldplot of electron phase space distribution

我是 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?我该怎么做?

任何帮助将不胜感激...谢谢

【问题讨论】:

    标签: python matplotlib


    【解决方案1】:

    只需将 xlim 设置为 -5 到 5:

    ax.set_xlim([-5,5])
    

    【讨论】:

    • 它成功了,谢谢,我看了很长时间,看不到明显的东西!谢谢
    • 如果这对您有用,您应该accept the answer 让其他人知道并将问题标记为已解决。
    猜你喜欢
    • 1970-01-01
    • 2023-04-06
    • 1970-01-01
    • 2013-07-14
    • 2019-02-22
    • 1970-01-01
    • 2020-01-22
    • 1970-01-01
    • 2011-05-11
    相关资源
    最近更新 更多