python - Printing labels in a loop -
i want loop , plot file information
-1 1 0.732313 -1 2 1.33585 -1 4 1.05306 -1 8 1.56261 -1 16 1.90336 -1 32 1.71105 -1 64 1.8319
which loaded mat0
have far:
mat0 = genfromtxt("mydata") fig1 = plt.figure() ax = fig1.add_subplot(111) mybel =-1 count =0 while (count < 60): i=count j= i+6 plt.plot(mat0[i:j,1], mat0[i:j,2],label="size %s"%mybel) count = count + 7 mybel = mybel +1 plt.show()
the problem not labels printed @ all. not error either. missing?
you need call legend
object. calling plt.legend()
.
mat0 = genfromtxt("mydata") fig1 = plt.figure() ax = fig1.add_subplot(111) mybel =-1 count =0 while (count < 60): i=count j= i+6 plt.plot(mat0[i:j,1], mat0[i:j,2],label="size %s"%mybel) count = count + 7 mybel = mybel +1 plt.legend() plt.show()
Comments
Post a Comment