Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 13094de

Browse files
committed
docstring and other cleanups; fixes bug 1605288
svn path=/trunk/matplotlib/; revision=3188
1 parent f64e5d2 commit 13094de

4 files changed

Lines changed: 39 additions & 33 deletions

File tree

lib/matplotlib/axes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2125,14 +2125,14 @@ def annotate(self, *args, **kwargs):
21252125
markerprops=None
21262126
**props)
21272127
2128-
%s
2128+
%(Annotation)s
21292129
"""
21302130
a = Annotation(*args, **kwargs)
21312131
a.set_transform(identity_transform())
21322132
self._set_artist_props(a)
21332133
self.texts.append(a)
21342134
return a
2135-
annotate.__doc__ = dedent(annotate.__doc__) % Annotation.__doc__
2135+
annotate.__doc__ = dedent(annotate.__doc__) % artist.kwdocd
21362136

21372137
#### Lines and spans
21382138

lib/matplotlib/cbook.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,8 @@ def dedent(s):
425425
deletion of leading blank lines and its use of the
426426
first non-blank line to determine the indentation.
427427
"""
428+
if not s: # includes case of s is None
429+
return ''
428430
lines = s.splitlines(True)
429431
ii = 0
430432
while lines[ii].strip() == '':

lib/matplotlib/pylab.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1500,13 +1500,6 @@ def box(on=None):
15001500
ax.set_frame_on(on)
15011501
draw_if_interactive()
15021502

1503-
def annotate(*args, **kwargs):
1504-
a = Annotation(*args, **kwargs)
1505-
ax = gca()
1506-
ax.add_artist(a)
1507-
draw_if_interactive()
1508-
annotate.__doc__ = "annotate(artist, s, loc=None, padx='auto', pady='auto', autopad=3, lineprops=None,**props)\n\n"+Annotation.__init__.__doc__
1509-
15101503
### Deprecated functions:
15111504
def scatter_classic(*args, **kwargs):
15121505
return gca().scatter_classic(*args, **kwargs)

lib/matplotlib/text.py

Lines changed: 35 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from __future__ import division
55
import re
66
from matplotlib import verbose
7+
from matplotlib import cbook
78
import matplotlib
89
import math
910
from artist import Artist
@@ -89,29 +90,10 @@ def get_rotation(rotation):
8990

9091
_unit_box = lbwh_to_bbox(0,0,1,1)
9192

92-
93-
class Text(Artist):
94-
"""
95-
Handle storing and drawing of text in window or data coordinates
96-
97-
"""
98-
# special case superscripting to speedup logplots
99-
_rgxsuper = re.compile('\$([\-+0-9]+)\^\{(-?[0-9]+)\}\$')
100-
101-
zorder = 3
102-
def __init__(self,
103-
x=0, y=0, text='',
104-
color=None, # defaults to rc params
105-
verticalalignment='bottom',
106-
horizontalalignment='left',
107-
multialignment=None,
108-
fontproperties=None, # defaults to FontProperties()
109-
rotation=None,
110-
**kwargs
111-
):
112-
"""
113-
Create a Text instance at x,y with string text. Valid kwargs are
114-
93+
# these are not available for the object inspector until after the
94+
# class is build so we define an initial set here for the init
95+
# function and they will be overridden after object defn
96+
artist.kwdocd['Text'] = """\
11597
alpha: float
11698
animated: [True | False]
11799
backgroundcolor: any matplotlib color
@@ -140,6 +122,30 @@ def __init__(self,
140122
x: float
141123
y: float
142124
zorder: any number
125+
"""
126+
127+
class Text(Artist):
128+
"""
129+
Handle storing and drawing of text in window or data coordinates
130+
131+
"""
132+
# special case superscripting to speedup logplots
133+
_rgxsuper = re.compile('\$([\-+0-9]+)\^\{(-?[0-9]+)\}\$')
134+
135+
zorder = 3
136+
def __init__(self,
137+
x=0, y=0, text='',
138+
color=None, # defaults to rc params
139+
verticalalignment='bottom',
140+
horizontalalignment='left',
141+
multialignment=None,
142+
fontproperties=None, # defaults to FontProperties()
143+
rotation=None,
144+
**kwargs
145+
):
146+
"""
147+
Create a Text instance at x,y with string text. Valid kwargs are
148+
%(Text)s
143149
"""
144150

145151
Artist.__init__(self)
@@ -160,6 +166,7 @@ def __init__(self,
160166
self._renderer = None
161167
self.update(kwargs)
162168
#self.set_bbox(dict(pad=0))
169+
__init__.__doc__ = cbook.dedent(__init__.__doc__) % artist.kwdocd
163170

164171

165172
def pick(self, mouseevent):
@@ -1595,7 +1602,7 @@ def __init__(self, s, xy,
15951602
annotated. If d is the distance between the text and
15961603
annotated point, shrink will shorten the arrow so the tip
15971604
and base are shink percent of the distance d away from the
1598-
endpoints. ie, shrink=0.05 is 5%
1605+
endpoints. ie, shrink=0.05 is 5%%
15991606
- any key for matplotlib.patches.polygon
16001607
16011608
xycoords and textcoords are a string that indicates the
@@ -1621,6 +1628,9 @@ def __init__(self, s, xy,
16211628
# 5 points below the top border
16221629
xy=(10,-5), xycoords='axes points'
16231630
1631+
Additional kwargs are Text properties:
1632+
1633+
%(Text)s
16241634
16251635
"""
16261636
if xytext is None:
@@ -1635,6 +1645,7 @@ def __init__(self, s, xy,
16351645
self.arrow = None
16361646
self.xycoords = xycoords
16371647
self.textcoords = textcoords
1648+
__init__.__doc__ = cbook.dedent(__init__.__doc__) % artist.kwdocd
16381649

16391650
def _get_xy(self, x, y, s):
16401651
if s=='data':

0 commit comments

Comments
 (0)