I was playing with twinx() a little tonight from the pylab.py file and have a small suggestion. I think twinx() should call (before creating the new axes):
Currently, after calling twinx(), then new axis tick marks correctly appear on the right side of the plot. However, the major tick marks from the left hand side Y axis also appear on the right side of the plot which is a little confusing.
Also, since we have twinx(), it would be nice to have twiny():
Make a second axes overlay ax (or the current axes if ax is None)
sharing the yaxis. The ticks for ax2 will be placed on the top,
and the ax2 instance is returned. See examples/two_scales.py
if ax is None:
ax2 = gcf().add_axes(ax.get_position(), sharey=ax, frameon=False)
The case I'm thinking of where twiny() would would be useful is one that we hit a lot at work. Time is represented on the X axis and we want multiple label types. So we'd like to have the bottom axis be time in UTC and the upper axis to be PST or some other local time frame. I'm not sure whether or not it would be best to replot the data using twiny() or to try and set up a custom formatter on the second X scale since in my scenario there aren't two sets of data.