Revision: 7178
          http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7178&view=rev
Author:   jdh2358
Date:     2009-06-05 13:00:47 +0000 (Fri, 05 Jun 2009)

Log Message:
-----------
added JJ's F/C two scale example

Added Paths:
-----------
    trunk/matplotlib/examples/api/fahrenheit_celcius_scales.py

Added: trunk/matplotlib/examples/api/fahrenheit_celcius_scales.py
===================================================================
--- trunk/matplotlib/examples/api/fahrenheit_celcius_scales.py                  
        (rev 0)
+++ trunk/matplotlib/examples/api/fahrenheit_celcius_scales.py  2009-06-05 
13:00:47 UTC (rev 7178)
@@ -0,0 +1,28 @@
+"""
+Shoiw how to display two scales on the left and right y axis -- Fahrenheit and 
Celcius
+"""
+
+import matplotlib.pyplot as plt
+
+fig = plt.figure()
+ax1 = fig.add_subplot(111)     # the Fahrenheit scale
+ax2 = ax1.twinx()              # the Celcius scale
+
+def Tc(Tf):
+    return (5./9.)*(Tf-32)
+
+
+def update_ax2(ax1):
+   y1, y2 = ax1.get_ylim()
+   ax2.set_ylim(Tc(y1), Tc(y2))
+   ax2.figure.canvas.draw()
+
+# automatically update ylim of ax2 when ylim of ax1 changes.
+ax1.callbacks.connect("ylim_changed", update_ax2)
+ax1.plot([78, 79, 79, 77])
+
+ax1.set_title('Two scales: Fahrenheit and Celcius')
+ax1.set_ylabel('Fahrenheit')
+ax2.set_ylabel('Celcius')
+
+plt.show()


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
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-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins

Reply via email to