Revision: 8158
          http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8158&view=rev
Author:   leejjoon
Date:     2010-02-26 00:28:14 +0000 (Fri, 26 Feb 2010)

Log Message:
-----------
add annotation_demo3.py

Modified Paths:
--------------
    trunk/matplotlib/CHANGELOG

Added Paths:
-----------
    trunk/matplotlib/examples/pylab_examples/annotation_demo3.py

Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG  2010-02-26 00:28:07 UTC (rev 8157)
+++ trunk/matplotlib/CHANGELOG  2010-02-26 00:28:14 UTC (rev 8158)
@@ -1,3 +1,5 @@
+2010-02-25 add annotation_demo3.py that demonstrates new functionality. -JJL
+
 2010-02-25 refactor Annotation to support arbitrary Transform as xycoords 
            or textcoords. Also, if a tuple of two coordinates is provided, 
            they are interpreted as coordinates for each x and y position. 

Added: trunk/matplotlib/examples/pylab_examples/annotation_demo3.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/annotation_demo3.py                
                (rev 0)
+++ trunk/matplotlib/examples/pylab_examples/annotation_demo3.py        
2010-02-26 00:28:14 UTC (rev 8158)
@@ -0,0 +1,102 @@
+import matplotlib.pyplot as plt
+
+fig = plt.figure(1)
+fig.clf()
+
+ax1 = plt.subplot(121)
+ax2 = plt.subplot(122)
+
+bbox_args = dict(boxstyle="round", fc="0.8")
+arrow_args = dict(arrowstyle="->")
+
+ax1.annotate('figure fraction : 0, 0', xy=(0, 0),  xycoords='figure fraction',
+             xytext=(20, 20), textcoords='offset points',
+             ha="left", va="bottom",
+             bbox=bbox_args,
+             arrowprops=arrow_args
+             )
+
+ax1.annotate('figure fraction : 1, 1', xy=(1, 1),  xycoords='figure fraction',
+             xytext=(-20, -20), textcoords='offset points',
+             ha="right", va="top",
+             bbox=bbox_args,
+             arrowprops=arrow_args
+             )
+
+ax1.annotate('axes fraction : 0, 0', xy=(0, 0),  xycoords='axes fraction',
+             xytext=(20, 20), textcoords='offset points',
+             ha="left", va="bottom",
+             bbox=bbox_args,
+             arrowprops=arrow_args
+             )
+
+ax1.annotate('axes fraction : 1, 1', xy=(1, 1),  xycoords='axes fraction',
+             xytext=(-20, -20), textcoords='offset points',
+             ha="right", va="top",
+             bbox=bbox_args,
+             arrowprops=arrow_args
+             )
+
+
+an1 = ax1.annotate('Drag me 1', xy=(.5, .7),  xycoords='data',
+                   #xytext=(.5, .7), textcoords='data',
+                   ha="center", va="center",
+                   bbox=bbox_args,
+                   #arrowprops=arrow_args
+                   )
+
+an2 = ax1.annotate('Drag me 2', xy=(.5, .5),  xycoords=an1,
+                   xytext=(.5, .3), textcoords='axes fraction',
+                   ha="center", va="center",
+                   bbox=bbox_args,
+                   arrowprops=dict(patchB=an1.get_bbox_patch(),
+                                   connectionstyle="arc3,rad=0.2",
+                                   **arrow_args)
+                   )
+
+an3 = ax1.annotate('', xy=(.5, .5),  xycoords=an2,
+                   xytext=(.5, .5),  textcoords=an1,
+                   ha="center", va="center",
+                   bbox=bbox_args,
+                   arrowprops=dict(patchA=an1.get_bbox_patch(),
+                                   patchB=an2.get_bbox_patch(),
+                                   connectionstyle="arc3,rad=0.2",
+                                   **arrow_args)
+                   )
+
+
+
+t = ax2.annotate('xy=(0, 1)\nxycoords=("data", "axes fraction")',
+                 xy=(0, 1),  xycoords=("data", 'axes fraction'),
+                 xytext=(0, -20), textcoords='offset points',
+                 ha="center", va="top",
+                 bbox=bbox_args,
+                 arrowprops=arrow_args
+                 )
+
+from matplotlib.text import OffsetFrom
+
+ax2.annotate('xy=(0.5, 0)\nxycoords="bbox fraction"\nxybbox=artist',
+             xy=(0.5, 0.),  xycoords=t.get_window_extent,
+             xytext=(0, -20), textcoords='offset points',
+             ha="center", va="top",
+             bbox=bbox_args,
+             arrowprops=arrow_args
+             )
+
+ax2.annotate('xy=(0.8, 0.5)\nxycoords="bbox"\nxybbox=ax1.transData',
+             xy=(0.8, 0.5),  xycoords=ax1.transData,
+             #xytext=(0, 0), textcoords='data',
+             xytext=(10, 10), textcoords=OffsetFrom(ax2.bbox, (0, 0), 
"points"),
+             ha="left", va="bottom",
+             bbox=bbox_args,
+             arrowprops=arrow_args
+             )
+
+ax2.set_xlim(-2, 2)
+ax2.set_ylim(-2, 2)
+
+an1.draggable()
+an2.draggable()
+
+plt.show()


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

------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Matplotlib-checkins mailing list
Matplotlib-checkins@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins

Reply via email to