0

I'm trying to make a plot with double y axis so I use plt.subplots()

let's say the two y axis has values like shown below

x = [0,0,0,0,0,0,0,0,0,0,0,0]

y1 = [1.3,1.2, 1.1, 1.0, 0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2]

y2 = [409.71, 243.016, 176.535, 120, 66.4234, 28.1243, 10.876, 2.95651, 0.70502, 0,0,0]

fig,ax = plt.subplots()

ax.scatter(x,y1)

ax2=ax.twinx()

ax2.scatter(x,y2)

plt.show()

so I get something like this

But I would like the point from the two y axis to coincide. I tried to manipulate the y-axis tick parameters but this might get complicated as I add more x points. (I will then add further x point such as x=0.2 and so on).

So basically I would have a straight line of points at different x values where both y correspond to a particular x.

Aligning the two axis will only overlap the first and the last point like this

But I would like to overlap all the points, for each y1(x) value I have a corresponding y2(x) value

I'm hoping someone here can show me how I could possibly achieve this. I'm very new to python so more explanation is appreciated. Thank you in advance for your help.

Rajam E
  • 7
  • 4

0 Answers0