Ankur
Ankur

Reputation: 477

Scaling the y axis in matplotlib

I want to draw multiple plots in the same plot so I took 2d list in which for one parameter it's storing the values in the string format and I am using the for loop for the same but when I am plotting the larger values on y axis are coming below the smaller values Here is the code snippet that might help to understand

m=['H','.','<','^','*','+','x','@']
    cnt=0
    for i in all:# here all has the row wise data to plot 
       matplotlib.pyplot.plot(l3,i,m[cnt])# l3 contains the values about the x axis
        cnt=cnt+1
    plt.xlabel("x")
    plt.ylabel("y")
    plt.legend(para,loc='best')# para contains the info about the y parameters

    plt.show()

The graph is coming like this how to get 12000 above 0 in the graph

This is the plot I got how to rescale it so that all values comes in acsending order on y axis

This is the plot I got how to rescale it so that all values comes in acsending order on y axis

Upvotes: 1

Views: 272

Answers (1)

Sheldore
Sheldore

Reputation: 39042

You have to convert strings to floats before plotting

for i in all:# here all has the row wise data to plot 
    y = [float(ii) for ii in i]    
    matplotlib.pyplot.plot(l3, y, m[cnt])# l3 contains the values about the x axis
    cnt=cnt+1

Upvotes: 1

Related Questions