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])

-JJ


On Thu, Jun 4, 2009 at 11:08 AM, musik <xi.xiaoxi...@gmail.com> wrote:
>
> Exactly. I want to plot the original data once, but the two y axes show
> different scales (units). Is twinx() good for that? How?
>
> Thanks.
>
>
>
> Ryan May-3 wrote:
>>
>> On Thu, Jun 4, 2009 at 6:01 AM, Sandro Tosi <matrixh...@gmail.com> wrote:
>>
>>> Hi,
>>>
>>> On Thu, Jun 4, 2009 at 06:56, musik <xi.xiaoxi...@gmail.com> wrote:
>>> > I want to make a plot with both y axes labeled. The one on the left
>>> (y1)
>>> > will be in Fahrenheit,  while the one on the right (y2) in Celsius. Is
>>> there
>>> > a way to do this?
>>>
>>> what you're looking for is [1]
>>>
>>> [1]
>>> http://matplotlib.sourceforge.net/api/pyplot_api.html?highlight=twinx#matplotlib.pyplot.twinx
>>
>>
>> Well you can make it work that way, but I think what the original poster
>> wants is just to plot the data once, with one set of units on the left and
>> another on the right.  Using twinx would make two identical lines just to
>> make two different scales.  It seems to me that there *should* be an
>> easier
>> way, but I'm not sure that one exists...
>>
>> Ryan
>>
>> --
>> Ryan May
>> Graduate Research Assistant
>> School of Meteorology
>> University of Oklahoma
>> Sent from Norman, Oklahoma, United States
>>
>> ------------------------------------------------------------------------------
>> OpenSolaris 2009.06 is a cutting edge operating system for enterprises
>> looking to deploy the next generation of Solaris that includes the latest
>> innovations from Sun and the OpenSource community. Download a copy and
>> enjoy capabilities such as Networking, Storage and Virtualization.
>> Go to: http://p.sf.net/sfu/opensolaris-get
>> _______________________________________________
>> Matplotlib-users mailing list
>> Matplotlib-users@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>
>>
>
> --
> View this message in context: 
> http://www.nabble.com/one-data-set%2C-two-y-axis-scales-tp23863680p23871873.html
> Sent from the matplotlib - users mailing list archive at Nabble.com.
>
>
> ------------------------------------------------------------------------------
> OpenSolaris 2009.06 is a cutting edge operating system for enterprises
> looking to deploy the next generation of Solaris that includes the latest
> innovations from Sun and the OpenSource community. Download a copy and
> enjoy capabilities such as Networking, Storage and Virtualization.
> Go to: http://p.sf.net/sfu/opensolaris-get
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>

------------------------------------------------------------------------------
OpenSolaris 2009.06 is a cutting edge operating system for enterprises 
looking to deploy the next generation of Solaris that includes the latest 
innovations from Sun and the OpenSource community. Download a copy and 
enjoy capabilities such as Networking, Storage and Virtualization. 
Go to: http://p.sf.net/sfu/opensolaris-get
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to