I am trying to plot wind speed and wind direction for multiple levels on one large series of subplots using plt.subplots()
.
I have:
fig, axes=plt.subplots(n=levels,figsize=(20,30),sharex=True)
for i in range(levels):
axes[i].plot(time,wind_speed[:,i])
How can I add the second y-axis on each subplot so I can plot wind speed and wind direction on the same plot for each level? I don't understand how do add a second axis second axes cannot be enumerated this way.
Each plot will have the same x-axis, but wind speed on a line plot (left y-axis) and wind direction as dots (right y-axis). twinx
would work but Python does not like twinx
when using iteration in a for loop.
I tried axes[0][i]=axes[i].twinx
I also tried to do a another nested for loop
with for j...
to do axes[j]=axes[i].twinx
. None of this worked.