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

Skip to content

Commit 465f604

Browse files
committed
Fix remaining pep8 issues in tutorials.
1 parent f20bc62 commit 465f604

6 files changed

Lines changed: 51 additions & 45 deletions

File tree

tutorials/02_intermediate/artists.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,7 @@ class in the matplotlib API, and the one you will be working with most
668668
# gridline Line2D instance
669669
# label1 Text instance
670670
# label2 Text instance
671-
# gridOn boolean which determines whether to draw the gridline
671+
# gridOn boolean which determines whether to draw the gridline
672672
# tick1On boolean which determines whether to draw the 1st tickline
673673
# tick2On boolean which determines whether to draw the 2nd tickline
674674
# label1On boolean which determines whether to draw the 1st tick label

tutorials/02_intermediate/legend_guide.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,9 +236,11 @@
236236

237237
import matplotlib.patches as mpatches
238238

239+
239240
class AnyObject(object):
240241
pass
241242

243+
242244
class AnyObjectHandler(object):
243245
def legend_artist(self, legend, orig_handle, fontsize, handlebox):
244246
x0, y0 = handlebox.xdescent, handlebox.ydescent
@@ -249,6 +251,7 @@ def legend_artist(self, legend, orig_handle, fontsize, handlebox):
249251
handlebox.add_artist(patch)
250252
return patch
251253

254+
252255
plt.legend([AnyObject()], ['My first handler'],
253256
handler_map={AnyObject: AnyObjectHandler()})
254257

@@ -267,6 +270,7 @@ def legend_artist(self, legend, orig_handle, fontsize, handlebox):
267270

268271
from matplotlib.legend_handler import HandlerPatch
269272

273+
270274
class HandlerEllipse(HandlerPatch):
271275
def create_artists(self, legend, orig_handle,
272276
xdescent, ydescent, width, height, fontsize, trans):

tutorials/03_advanced/path_tutorial.py

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,20 @@
1919
import matplotlib.patches as patches
2020

2121
verts = [
22-
(0., 0.), # left, bottom
23-
(0., 1.), # left, top
24-
(1., 1.), # right, top
25-
(1., 0.), # right, bottom
26-
(0., 0.), # ignored
27-
]
28-
29-
codes = [Path.MOVETO,
30-
Path.LINETO,
31-
Path.LINETO,
32-
Path.LINETO,
33-
Path.CLOSEPOLY,
34-
]
22+
(0., 0.), # left, bottom
23+
(0., 1.), # left, top
24+
(1., 1.), # right, top
25+
(1., 0.), # right, bottom
26+
(0., 0.), # ignored
27+
]
28+
29+
codes = [
30+
Path.MOVETO,
31+
Path.LINETO,
32+
Path.LINETO,
33+
Path.LINETO,
34+
Path.CLOSEPOLY,
35+
]
3536

3637
path = Path(verts, codes)
3738

@@ -75,17 +76,18 @@
7576
# point
7677

7778
verts = [
78-
(0., 0.), # P0
79-
(0.2, 1.), # P1
80-
(1., 0.8), # P2
81-
(0.8, 0.), # P3
82-
]
83-
84-
codes = [Path.MOVETO,
85-
Path.CURVE4,
86-
Path.CURVE4,
87-
Path.CURVE4,
88-
]
79+
(0., 0.), # P0
80+
(0.2, 1.), # P1
81+
(1., 0.8), # P2
82+
(0.8, 0.), # P3
83+
]
84+
85+
codes = [
86+
Path.MOVETO,
87+
Path.CURVE4,
88+
Path.CURVE4,
89+
Path.CURVE4,
90+
]
8991

9092
path = Path(verts, codes)
9193

tutorials/03_advanced/transforms_tutorial.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@
2424
Coordinate Transformation Object Description
2525
========== ===================== ====================================================================================
2626
`data` ``ax.transData`` The userland data coordinate system, controlled by the xlim and ylim
27-
`axes` ``ax.transAxes`` The coordinate system of the :class:`~matplotlib.axes.Axes`; (0,0) is
28-
bottom left of the axes, and (1,1) is top right of the axes.
29-
`figure` ``fig.transFigure`` The coordinate system of the :class:`~matplotlib.figure.Figure`; (0,0)
30-
is bottom left of the figure, and (1,1) is top right of the figure.
31-
`display` `None` This is the pixel coordinate system of the display; (0,0) is the bottom
27+
`axes` ``ax.transAxes`` The coordinate system of the :class:`~matplotlib.axes.Axes`; (0, 0) is
28+
bottom left of the axes, and (1, 1) is top right of the axes.
29+
`figure` ``fig.transFigure`` The coordinate system of the :class:`~matplotlib.figure.Figure`; (0, 0)
30+
is bottom left of the figure, and (1, 1) is top right of the figure.
31+
`display` `None` This is the pixel coordinate system of the display; (0, 0) is the bottom
3232
left of the display, and (width, height) is the top right of the display in pixels.
3333
Alternatively, the identity transform
3434
(:class:`matplotlib.transforms.IdentityTransform()`) may be used instead of None.
@@ -87,7 +87,7 @@
8787
# In [15]: ax.transData.transform((5, 0))
8888
# Out[15]: array([ 335.175, 247. ])
8989
#
90-
# In [16]: ax.transData.transform([(5, 0), (1,2)])
90+
# In [16]: ax.transData.transform([(5, 0), (1, 2)])
9191
# Out[16]:
9292
# array([[ 335.175, 247. ],
9393
# [ 132.435, 642.2 ]])
@@ -170,13 +170,13 @@
170170
# In [54]: ax.transData.transform((5, 0))
171171
# Out[54]: array([ 335.175, 247. ])
172172
#
173-
# In [55]: ax.set_ylim(-1,2)
173+
# In [55]: ax.set_ylim(-1, 2)
174174
# Out[55]: (-1, 2)
175175
#
176176
# In [56]: ax.transData.transform((5, 0))
177177
# Out[56]: array([ 335.175 , 181.13333333])
178178
#
179-
# In [57]: ax.set_xlim(10,20)
179+
# In [57]: ax.set_xlim(10, 20)
180180
# Out[57]: (10, 20)
181181
#
182182
# In [58]: ax.transData.transform((5, 0))
@@ -189,7 +189,7 @@
189189
# ================
190190
#
191191
# After the `data` coordinate system, `axes` is probably the second most
192-
# useful coordinate system. Here the point (0,0) is the bottom left of
192+
# useful coordinate system. Here the point (0, 0) is the bottom left of
193193
# your axes or subplot, (0.5, 0.5) is the center, and (1.0, 1.0) is the
194194
# top right. You can also refer to points outside the range, so (-0.1,
195195
# 1.1) is to the left and above your axes. This coordinate system is
@@ -272,7 +272,7 @@
272272
# highlight the 1..2 stddev region with a span.
273273
# We want x to be in data coordinates and y to
274274
# span from 0..1 in axes coords
275-
rect = patches.Rectangle((1,0), width=1, height=1,
275+
rect = patches.Rectangle((1, 0), width=1, height=1,
276276
transform=trans, color='yellow',
277277
alpha=0.5)
278278

@@ -389,7 +389,7 @@
389389
# self.transData = self.transScale + (self.transLimits + self.transAxes)
390390
#
391391
# We've been introduced to the ``transAxes`` instance above in
392-
# :ref:`axes-coords`, which maps the (0,0), (1,1) corners of the
392+
# :ref:`axes-coords`, which maps the (0, 0), (1, 1) corners of the
393393
# axes or subplot bounding box to `display` space, so let's look at
394394
# these other two pieces.
395395
#
@@ -405,19 +405,19 @@
405405
# In [81]: ax.set_xlim(0, 10)
406406
# Out[81]: (0, 10)
407407
#
408-
# In [82]: ax.set_ylim(-1,1)
408+
# In [82]: ax.set_ylim(-1, 1)
409409
# Out[82]: (-1, 1)
410410
#
411-
# In [84]: ax.transLimits.transform((0,-1))
411+
# In [84]: ax.transLimits.transform((0, -1))
412412
# Out[84]: array([ 0., 0.])
413413
#
414-
# In [85]: ax.transLimits.transform((10,-1))
414+
# In [85]: ax.transLimits.transform((10, -1))
415415
# Out[85]: array([ 1., 0.])
416416
#
417-
# In [86]: ax.transLimits.transform((10,1))
417+
# In [86]: ax.transLimits.transform((10, 1))
418418
# Out[86]: array([ 1., 1.])
419419
#
420-
# In [87]: ax.transLimits.transform((5,0))
420+
# In [87]: ax.transLimits.transform((5, 0))
421421
# Out[87]: array([ 0.5, 0.5])
422422
#
423423
# and we can use this same inverted transformation to go from the unit

tutorials/colors/colormaps.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
perceives changes in the lightness parameter as changes in the data
2828
much better than, for example, changes in hue. Therefore, colormaps
2929
which have monotonically increasing lightness through the colormap
30-
will be better interpreted by the viewer. A wonderful example of
30+
will be better interpreted by the viewer. A wonderful example of
3131
perceptually uniform colormaps is [colorcet]_.
3232
3333
Color can be represented in 3D space in various ways. One way to represent color
@@ -340,11 +340,11 @@ def plot_color_gradients(cmap_category, cmap_list):
340340
for ax, name in zip(axes, cmap_list):
341341

342342
# Get RGB values for colormap.
343-
rgb = cm.get_cmap(plt.get_cmap(name))(x)[np.newaxis,:,:3]
343+
rgb = cm.get_cmap(plt.get_cmap(name))(x)[np.newaxis, :, :3]
344344

345345
# Get colormap in CAM02-UCS colorspace. We want the lightness.
346346
lab = cspace_converter("sRGB1", "CAM02-UCS")(rgb)
347-
L = lab[0,:,0]
347+
L = lab[0, :, 0]
348348
L = np.float32(np.vstack((L, L, L)))
349349

350350
ax[0].imshow(gradient, aspect='auto', cmap=plt.get_cmap(name))

tutorials/text/text_intro.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
Matplotlib has extensive text support, including support for
88
mathematical expressions, truetype support for raster and
99
vector outputs, newline separated text with arbitrary
10-
rotations, and unicode support.
10+
rotations, and unicode support.
1111
1212
Because it embeds fonts directly in output documents, e.g., for postscript
1313
or PDF, what you see on the screen is what you get in the hardcopy.

0 commit comments

Comments
 (0)