Why is set_xlim() not setting the x-limits in my figure?
matplotlib, python
Solution
Out of curiosity, what about switching in the old `xmin` and `xmax`?
fig=plt.figure()
ax=fig.add_subplot(111)
ax.plot(x_data,y_data)
ax.set_xlim(xmin=0.0, xmax=1000)
plt.savefig(filename)
Problem
I'm plotting some data with matplotlib. I want the plot to focus on a specific range of x-values, so I'm using set_xlim(). Roughly, my code looks like this: ``` fig=plt.figure() ax=fig.add_subplot(111) for ydata in ydatalist: ax.plot(x_data,y_data[0],label=ydata[1]) ax.set_xlim(left=0.0,right=1000) plt.savefig(filename) ``` When I look at the plot, the x range ends up being from 0 to 12000. This occurs whether set_xlim() occurs before or after plot(). Why is set_xlim() not working in this situation?