Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project!

## Re: [Matplotlib-users] one data set, two y axis scales

 Re: [Matplotlib-users] one data set, two y axis scales From: John Hunter - 2009-06-05 13:02:47 ```On Thu, Jun 4, 2009 at 12:16 PM, Jae-Joon Lee wrote: > I hope the code below gives you some idea. > > > def Tc(Tf): return (5./9.)*(Tf-32) > > ax1 = subplot(111) # y-axis in F > ax2 = twinx() # y-axis in C > > def update_ax2(ax1): > y1, y2 = ax1.get_ylim() > ax2.set_ylim(Tc(y1), Tc(y2)) > > # automatically update ylim of ax2 when ylim of ax1 changes. > ax1.callbacks.connect("ylim_changed", update_ax2) > ax1.plot([78, 79, 79, 77]) Yes, this is a cute little example. I was thinking along the lines Ryan was, to just plot the same data twice with twinx, but this is cleverer. I added it to svn as: examples/api/fahrenheit_celcius_scales.py But using twinx has always been a hack. I think what we really need is to have each spine have it's own locator, formatter and tick collection (eg the natural points for Celcius ticks are different from the natural points for Fahrenheit ticks) and currently the left and right ticks of an axis share the axis locator and formatter. Currently the spines just draw the lines and the axes/axis handle all the ticks and the locators. It might be more natural to move these into the spine itself, and support independent ticks/locators/formatter for each spine, with the default being shared. Andrew, did you give this any thought in the spine implementation? I am pretty sure it would be hard, but maybe you have a better sense of *how hard*. This would be a nice enhancement. JDH ```