|
From: <lee...@us...> - 2009-12-11 16:58:01
|
Revision: 8023
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8023&view=rev
Author: leejjoon
Date: 2009-12-11 16:57:53 +0000 (Fri, 11 Dec 2009)
Log Message:
-----------
add ArrowStyle |-|
Modified Paths:
--------------
trunk/matplotlib/examples/pylab_examples/fancyarrow_demo.py
trunk/matplotlib/lib/matplotlib/patches.py
Modified: trunk/matplotlib/examples/pylab_examples/fancyarrow_demo.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/fancyarrow_demo.py 2009-12-11 16:57:46 UTC (rev 8022)
+++ trunk/matplotlib/examples/pylab_examples/fancyarrow_demo.py 2009-12-11 16:57:53 UTC (rev 8023)
@@ -4,7 +4,7 @@
styles = mpatches.ArrowStyle.get_styles()
ncol=2
-nrow = len(styles) // ncol + 1
+nrow = (len(styles)+1) // ncol
figheight = (nrow+0.5)
fig1 = plt.figure(1, (4.*ncol/1.5, figheight/1.5))
fontsize = 0.2 * 70
@@ -15,13 +15,19 @@
ax.set_xlim(0, 4*ncol)
ax.set_ylim(0, figheight)
+def to_texstring(s):
+ s = s.replace("<", r"$<$")
+ s = s.replace(">", r"$>$")
+ s = s.replace("|", r"$|$")
+ return s
+
for i, (stylename, styleclass) in enumerate(sorted(styles.items())):
x = 3.2 + (i//nrow)*4
y = (figheight - 0.7 - i%nrow) # /figheight
p = mpatches.Circle((x, y), 0.2, fc="w")
ax.add_patch(p)
- ax.annotate(stylename, (x, y),
+ ax.annotate(to_texstring(stylename), (x, y),
(x-1.2, y),
#xycoords="figure fraction", textcoords="figure fraction",
ha="right", va="center",
Modified: trunk/matplotlib/lib/matplotlib/patches.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/patches.py 2009-12-11 16:57:46 UTC (rev 8022)
+++ trunk/matplotlib/lib/matplotlib/patches.py 2009-12-11 16:57:53 UTC (rev 8023)
@@ -3299,6 +3299,41 @@
_style_list["-["] = BracketB
+ class BarAB(_Bracket):
+ """
+ An arrow with a bracket(]) at both ends.
+ """
+
+ def __init__(self,
+ widthA=1., angleA=None,
+ widthB=1., angleB=None):
+ """
+ *widthA*
+ width of the bracket
+
+ *lengthA*
+ length of the bracket
+
+ *angleA*
+ angle between the bracket and the line
+
+ *widthB*
+ width of the bracket
+
+ *lengthB*
+ length of the bracket
+
+ *angleB*
+ angle between the bracket and the line
+ """
+
+ super(ArrowStyle.BarAB, self).__init__(True, True, \
+ widthA=widthA, lengthA=0, angleA=angleA,
+ widthB=widthB, lengthB=0, angleB=angleB)
+
+ _style_list["|-|"] = BarAB
+
+
class Simple(_Base):
"""
A simple arrow. Only works with a quadratic bezier curve.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|