I have a loop which for a certain condition (occurs e.g 3 times), I'd like to plot two dataset with twinx, so e.g at the end I have 3 plots on left-y and 3 plots on right-y. When I use the usual twinx, the loop takes incorrect values for right-y. How should I modify this example code to get them correct? Thank you very much!
import numpy as np
import matplotlib.pyplot as plt
x=np.linspace(0,10,100)
A=5
fig,ax=plt.subplots()
for i in range(0,10):
A=i**2
if(i%3==0):
ax.plot(x,A*np.sin(x),'-ro')
ax2=ax.twinx()
ax2.plot(x,A*x,'-bp')
plt.show()