I need some clarification of add_subplot: in example below, i have 2 subplots, twinned on the y axis. I want to manipulate each axis, but don't get it!
import matplotlib.pyplot as plt
fig = plt.figure()
axes1 = fig.add_subplot(111)
axes2 = axes1.twiny() # share the y-axis
axes1.plot( somedata[:,2], somedata[:,1], label='axis1' )
axes2.plot( somedata[:,3], somedata[:,1], label='axis2' )
plt.legend()
plt.show()
I tried to set the limits on each x axis: axes1.set_data_interval(0, 300)
, which fails.
Labels in the legend only appear for the second axis, axes2. Again, I don't understand how this worked, or how to change it. I guess the latest command (axes2.plt()
) leaves that axis as the active one for the plot. How would I manipulate this explicitly?