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

Skip to content

Commit 1e32bdf

Browse files
committed
Improved docstrings, mainly annotate, base pylab
svn path=/trunk/matplotlib/; revision=3533
1 parent 078d6c0 commit 1e32bdf

7 files changed

Lines changed: 68 additions & 63 deletions

File tree

lib/matplotlib/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
This is a matlab(TM) style functional interface the matplotlib.
2+
This is an object-orient plotting library.
33
44
The following matlab(TM) compatible commands are provided by
55
@@ -901,4 +901,4 @@ def __init__(self, modstr):
901901
basemod = __import__(wholename)
902902
mod = getattr(basemod, name)
903903
setattr(self, name, mod)
904-
904+

lib/matplotlib/artist.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -136,27 +136,27 @@ def hitlist(self,event):
136136
if hasattr(self,'get_children'):
137137
for a in self.get_children(): L.extend(a.hitlist(event))
138138
return L
139-
139+
140140
def contains(self,mouseevent):
141-
"""Test whether the artist contains the mouse event.
142-
143-
Returns the truth value and a dictionary of artist specific details of
144-
selection, such as which points are contained in the pick radius. See
141+
"""Test whether the artist contains the mouse event.
142+
143+
Returns the truth value and a dictionary of artist specific details of
144+
selection, such as which points are contained in the pick radius. See
145145
individual artists for details.
146146
"""
147147
if callable(self._contains): return self._contains(self,mouseevent)
148148
#raise NotImplementedError,str(self.__class__)+" needs 'contains' method"
149149
print str(self.__class__)+" needs 'contains' method"
150150
return False,{}
151-
151+
152152
def set_contains(self,picker):
153153
"""Replace the contains test used by this artist. The new picker should
154154
be a callable function which determines whether the artist is hit by the
155155
mouse event:
156156
157157
hit, props = picker(artist, mouseevent)
158158
159-
If the mouse event is over the artist, return hit=True and props
159+
If the mouse event is over the artist, return hit=True and props
160160
is a dictionary of properties you want returned with the contains test.
161161
"""
162162
self._contains = picker
@@ -680,7 +680,7 @@ def setp(h, *args, **kwargs):
680680
return [x for x in flatten(ret)]
681681

682682
def kwdoc(a):
683-
return '\n'.join(ArtistInspector(a).pprint_setters(leadingspace=8))
683+
return '\n'.join(ArtistInspector(a).pprint_setters(leadingspace=4))
684684

685685
kwdocd = dict()
686686
kwdocd['Artist'] = kwdoc(Artist)

lib/matplotlib/axes.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
rcParams = matplotlib.rcParams
1010

1111
# import a bunch of matplotlib modules into a single namespace
12-
mpl = matplotlib.Importer("""artist, agg, axis, cbook, collections, colors,
13-
contour, dates, font_manager, image, legend, lines, mlab, cm,
12+
mpl = matplotlib.Importer("""artist, agg, axis, cbook, collections, colors,
13+
contour, dates, font_manager, image, legend, lines, mlab, cm,
1414
patches, quiver, table, text, ticker, transforms""")
1515

1616
def delete_masked_points(*args):
@@ -2136,10 +2136,11 @@ def text(self, x, y, s, fontdict=None,
21362136

21372137
def annotate(self, *args, **kwargs):
21382138
"""
2139-
annotate(self, s, xy, textloc,
2140-
xycoords='data', textcoords='data',
2141-
lineprops=None,
2142-
markerprops=None
2139+
annotate(s, xy,
2140+
xytext=None,
2141+
xycoords='data',
2142+
textcoords='data',
2143+
arrowprops=None,
21432144
**props)
21442145
21452146
%(Annotation)s
@@ -4242,7 +4243,7 @@ def fill(self, *args, **kwargs):
42424243
axes.fill(xs, ys, facecolor='red', alpha=0.5)
42434244
42444245
See examples/fill_between.py for more examples.
4245-
4246+
42464247
kwargs control the Polygon properties:
42474248
%(Polygon)s
42484249
"""

lib/matplotlib/cbook.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ def dedent(s):
546546
"""
547547
if not s: # includes case of s is None
548548
return ''
549-
lines = s.splitlines(True)
549+
lines = s.splitlines(False)
550550
ii = 0
551551
while lines[ii].strip() == '':
552552
ii += 1
@@ -555,7 +555,7 @@ def dedent(s):
555555
for i, line in enumerate(lines):
556556
nwhite = len(line) - len(line.lstrip())
557557
lines[i] = line[min(nshift, nwhite):]
558-
return ''.join(lines)
558+
return '\n'.join(lines)
559559

560560

561561

@@ -906,7 +906,7 @@ def print_path(path):
906906
outstream.write(repr(step))
907907
outstream.write(" ->\n")
908908
outstream.write("\n")
909-
909+
910910
def recurse(obj, start, all, current_path):
911911
if show_progress:
912912
outstream.write("%d\r" % len(all))
@@ -923,7 +923,7 @@ def recurse(obj, start, all, current_path):
923923
# Don't go back through the original list of objects, or
924924
# through temporary references to the object, since those
925925
# are just an artifact of the cycle detector itself.
926-
elif referent is objects or isinstance(referent, FrameType):
926+
elif referent is objects or isinstance(referent, FrameType):
927927
continue
928928

929929
# We haven't seen this object before, so recurse

lib/matplotlib/pylab.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
"""
2-
This is a procedural interface to matplotlib.
2+
This is a procedural interface to the matplotlib object-oriented
3+
plotting library.
34
4-
The following plotting commands are provided; some of these do not
5-
exist in matlab(TM) but have proven themselves to be useful nonetheless.
6-
The majority of them, however, have matlab analogs
5+
The following plotting commands are provided; the majority have
6+
Matlab(TM) analogs and similar argument.
77
88
_Plotting commands
99
acorr - plot the autocorrelation function

lib/matplotlib/text.py

Lines changed: 40 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -94,36 +94,36 @@ def get_rotation(rotation):
9494
# class is build so we define an initial set here for the init
9595
# function and they will be overridden after object defn
9696
artist.kwdocd['Text'] = """\
97-
alpha: float
98-
animated: [True | False]
99-
backgroundcolor: any matplotlib color
100-
bbox: rectangle prop dict plus key 'pad' which is a pad in points
101-
clip_box: a matplotlib.transform.Bbox instance
102-
clip_on: [True | False]
103-
color: any matplotlib color
104-
family: [ 'serif' | 'sans-serif' | 'cursive' | 'fantasy' | 'monospace' ]
105-
figure: a matplotlib.figure.Figure instance
106-
fontproperties: a matplotlib.font_manager.FontProperties instance
107-
horizontalalignment or ha: [ 'center' | 'right' | 'left' ]
108-
label: any string
109-
linespacing: float
110-
lod: [True | False]
111-
multialignment: ['left' | 'right' | 'center' ]
112-
name or fontname: string eg, ['Sans' | 'Courier' | 'Helvetica' ...]
113-
position: (x,y)
114-
rotation: [ angle in degrees 'vertical' | 'horizontal'
115-
size or fontsize: [ size in points | relative size eg 'smaller', 'x-large' ]
116-
style or fontstyle: [ 'normal' | 'italic' | 'oblique']
117-
text: string
118-
transform: a matplotlib.transform transformation instance
119-
variant: [ 'normal' | 'small-caps' ]
120-
verticalalignment or va: [ 'center' | 'top' | 'bottom' ]
121-
visible: [True | False]
122-
weight or fontweight: [ 'normal' | 'bold' | 'heavy' | 'light' | 'ultrabold' | 'ultralight']
123-
x: float
124-
y: float
125-
zorder: any number
126-
"""
97+
alpha: float
98+
animated: [True | False]
99+
backgroundcolor: any matplotlib color
100+
bbox: rectangle prop dict plus key 'pad' which is a pad in points
101+
clip_box: a matplotlib.transform.Bbox instance
102+
clip_on: [True | False]
103+
color: any matplotlib color
104+
family: [ 'serif' | 'sans-serif' | 'cursive' | 'fantasy' | 'monospace' ]
105+
figure: a matplotlib.figure.Figure instance
106+
fontproperties: a matplotlib.font_manager.FontProperties instance
107+
horizontalalignment or ha: [ 'center' | 'right' | 'left' ]
108+
label: any string
109+
linespacing: float
110+
lod: [True | False]
111+
multialignment: ['left' | 'right' | 'center' ]
112+
name or fontname: string eg, ['Sans' | 'Courier' | 'Helvetica' ...]
113+
position: (x,y)
114+
rotation: [ angle in degrees 'vertical' | 'horizontal'
115+
size or fontsize: [ size in points | relative size eg 'smaller', 'x-large' ]
116+
style or fontstyle: [ 'normal' | 'italic' | 'oblique']
117+
text: string
118+
transform: a matplotlib.transform transformation instance
119+
variant: [ 'normal' | 'small-caps' ]
120+
verticalalignment or va: [ 'center' | 'top' | 'bottom' ]
121+
visible: [True | False]
122+
weight or fontweight: [ 'normal' | 'bold' | 'heavy' | 'light' | 'ultrabold' | 'ultralight']
123+
x: float
124+
y: float
125+
zorder: any number
126+
"""
127127

128128
class Text(Artist):
129129
"""
@@ -149,8 +149,10 @@ def __init__(self,
149149
**kwargs
150150
):
151151
"""
152-
Create a Text instance at x,y with string text. Valid kwargs are
153-
%(Text)s
152+
Create a Text instance at x,y with string text.
153+
154+
Valid kwargs are
155+
%(Text)s
154156
"""
155157

156158
Artist.__init__(self)
@@ -817,6 +819,7 @@ def _get_layout_super(self, renderer, m):
817819

818820
return val
819821

822+
artist.kwdocd['Text'] = artist.kwdoc(Text)
820823

821824

822825
class TextWithDash(Text):
@@ -1125,6 +1128,7 @@ def set_figure(self, fig):
11251128
Text.set_figure(self, fig)
11261129
self.dashline.set_figure(fig)
11271130

1131+
artist.kwdocd['TextWithDash'] = artist.kwdoc(TextWithDash)
11281132

11291133
class Annotation(Text):
11301134
"""
@@ -1134,8 +1138,8 @@ class Annotation(Text):
11341138
def __str__(self):
11351139
return "Annotation(%g,%g,%s)"%(self.xy[0],self.xy[1],self._text)
11361140
def __init__(self, s, xy,
1137-
xycoords='data',
11381141
xytext=None,
1142+
xycoords='data',
11391143
textcoords=None,
11401144
arrowprops=None,
11411145
**kwargs):
@@ -1159,7 +1163,7 @@ def __init__(self, s, xy,
11591163
endpoints. ie, shrink=0.05 is 5%%
11601164
- any key for matplotlib.patches.polygon
11611165
1162-
xycoords and textcoords are a string that indicates the
1166+
xycoords and textcoords are strings that indicate the
11631167
coordinates of xy and xytext.
11641168
11651169
'figure points' : points from the lower left corner of the figure
@@ -1184,7 +1188,7 @@ def __init__(self, s, xy,
11841188
11851189
Additional kwargs are Text properties:
11861190
1187-
%(Text)s
1191+
%(Text)s
11881192
11891193
"""
11901194
if xytext is None:
@@ -1344,6 +1348,4 @@ def draw(self, renderer):
13441348
Text.draw(self, renderer)
13451349

13461350

1347-
artist.kwdocd['Text'] = artist.kwdoc(Text)
1348-
artist.kwdocd['TextWithDash'] = artist.kwdoc(TextWithDash)
1349-
artist.kwdocd['Annotation'] = artist.kwdoc(Annotation)
1351+
artist.kwdocd['Annotation'] = Annotation.__init__.__doc__

lib/pylab.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
from matplotlib.pylab import *
2+
import matplotlib.pylab
3+
__doc__ = matplotlib.pylab.__doc__

0 commit comments

Comments
 (0)