[Tutor] matmolplot

Evert Rol evert.rol at gmail.com
Tue Jun 1 17:59:52 CEST 2010

Sorry, forgot to reply-to-all previously.

> Hi,
> I am trying to make plot using following code:
> -----------


> for i in range(len(l2)):
> plt.axvline(x=l1[i], ymin=0, ymax=l2[i], linewidth=2, color='r')

axvline uses the [0, 1] range for it coordinates, not the coordinates set by the y-axis (which are set by the data): http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.axvline (which states "With the default values of ymin = 0 and ymax = 1, this line will always span the vertical extent of the axes, regardless of the ylim settings...")

You don't readily notice it, since your data lies in roughly the same [0, 1] interval. If your data were in the [0, 10] interval, you would have immediately spotted it.

Why don't you use eg:
plt.bar(left=l1, height=l2)

(which also removes the extra for loop)


> plt.axis([350, 650, 0.0, max(l2)])
> plt.grid(True)
> savefig(f2[0]+"-"+"uv.png",dpi=(600/8))
> plt.show()
> ----------------
> My problem is the output plot I am getting is not showing correct values in the plot as are in the input file (MS.txt - attached). It looks like it is scaled to lower value.

More information about the Tutor mailing list