0

plot of electric fieldplot of electron phase space distribution

I am new to Python, I have this script to generate the plots attached,

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')

I want to make the x axis longer e.g. from -5 to 5? How do I do this?

Any help would be greatly appreciated...thanks

S.M
  • 11
  • 1
  • 2

1 Answers1

4

Simply set the xlim to be -5 to 5:

ax.set_xlim([-5,5])
Scimonster
  • 32,893
  • 9
  • 77
  • 89
  • It worked thanks, I was looking at it for so long I couldn't see the obvisous! thanks – S.M Jun 22 '16 at 09:58
  • 1
    If this worked for you, you should [accept the answer](http://stackoverflow.com/help/accepted-answer) to let others know and mark the question as solved. – Scimonster Jun 22 '16 at 10:00