SourceForge logo
SourceForge logo
Menu

[matplotlib-devel] Suggestion(s) for twinx()

From: Ted D. <ted...@jp...> - 2005年05月20日 03:42:38
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):
gca().yaxis.tick_left()
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():
def twiny(ax=None):
 """
 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:
 ax=gca()
 ax.xaxis.tick_bottom()
	
 ax2 = gcf().add_axes(ax.get_position(), sharey=ax, frameon=False)
 ax2.xaxis.tick_top()
 ax2.xaxis.set_label_position('top')
 draw_if_interactive()
 return ax2
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.
Ted

View entire thread

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /