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

Skip to content

Commit 529882f

Browse files
committed
Fix overly long lines in examples & tutorials.
1 parent 52485ff commit 529882f

34 files changed

+435
-425
lines changed

.flake8

Lines changed: 19 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -76,24 +76,23 @@ per-file-ignores =
7676
lib/pylab.py: F401, F403
7777

7878
doc/conf.py: E402, E501
79-
tutorials/advanced/path_tutorial.py: E402, E501
80-
tutorials/advanced/patheffects_guide.py: E402, E501
79+
tutorials/advanced/path_tutorial.py: E402
80+
tutorials/advanced/patheffects_guide.py: E402
8181
tutorials/advanced/transforms_tutorial.py: E402, E501
8282
tutorials/colors/colormaps.py: E501
8383
tutorials/colors/colors.py: E402
8484
tutorials/colors/colormap-manipulation.py: E402
85-
tutorials/intermediate/artists.py: E402, E501
85+
tutorials/intermediate/artists.py: E402
8686
tutorials/intermediate/constrainedlayout_guide.py: E402
87-
tutorials/intermediate/gridspec.py: E402, E501
88-
tutorials/intermediate/legend_guide.py: E402, E501
89-
tutorials/intermediate/tight_layout_guide.py: E402, E501
87+
tutorials/intermediate/gridspec.py: E402
88+
tutorials/intermediate/legend_guide.py: E402
89+
tutorials/intermediate/tight_layout_guide.py: E402
9090
tutorials/introductory/customizing.py: E501
9191
tutorials/introductory/images.py: E402, E501
9292
tutorials/introductory/pyplot.py: E402, E501
9393
tutorials/introductory/sample_plots.py: E501
9494
tutorials/introductory/usage.py: E501
9595
tutorials/text/annotations.py: E501
96-
tutorials/text/pgf.py: E501
9796
tutorials/text/text_intro.py: E402
9897
tutorials/text/text_props.py: E501
9998
tutorials/text/usetex.py: E501
@@ -112,18 +111,13 @@ per-file-ignores =
112111
examples/color/colormap_reference.py: E402
113112
examples/color/custom_cmap.py: E402
114113
examples/color/named_colors.py: E402
115-
examples/event_handling/data_browser.py: E501
116-
examples/event_handling/path_editor.py: E501
117-
examples/event_handling/pick_event_demo.py: E501
118-
examples/event_handling/poly_editor.py: E501
119-
examples/event_handling/viewlims.py: E501
120114
examples/images_contours_and_fields/affine_image.py: E402
121115
examples/images_contours_and_fields/barb_demo.py: E402
122116
examples/images_contours_and_fields/barcode_demo.py: E402
123117
examples/images_contours_and_fields/contour_corner_mask.py: E402
124-
examples/images_contours_and_fields/contour_demo.py: E402, E501
118+
examples/images_contours_and_fields/contour_demo.py: E402
125119
examples/images_contours_and_fields/contour_image.py: E402
126-
examples/images_contours_and_fields/contourf_demo.py: E402, E501
120+
examples/images_contours_and_fields/contourf_demo.py: E402
127121
examples/images_contours_and_fields/contourf_hatching.py: E402
128122
examples/images_contours_and_fields/contourf_log.py: E402
129123
examples/images_contours_and_fields/demo_bboximage.py: E402
@@ -143,8 +137,8 @@ per-file-ignores =
143137
examples/images_contours_and_fields/quadmesh_demo.py: E402
144138
examples/images_contours_and_fields/quiver_demo.py: E402
145139
examples/images_contours_and_fields/quiver_simple_demo.py: E402
146-
examples/images_contours_and_fields/shading_example.py: E402, E501
147-
examples/images_contours_and_fields/specgram_demo.py: E402, E501
140+
examples/images_contours_and_fields/shading_example.py: E402
141+
examples/images_contours_and_fields/specgram_demo.py: E402
148142
examples/images_contours_and_fields/spy_demos.py: E402
149143
examples/images_contours_and_fields/tricontour_demo.py: E201, E402
150144
examples/images_contours_and_fields/tricontour_smooth_delaunay.py: E402
@@ -169,17 +163,11 @@ per-file-ignores =
169163
examples/lines_bars_and_markers/timeline.py: E402
170164
examples/lines_bars_and_markers/xcorr_acorr_demo.py: E402
171165
examples/misc/agg_buffer.py: E402
172-
examples/misc/anchored_artists.py: E501
173-
examples/misc/contour_manual.py: E501
174-
examples/misc/font_indexing.py: E501
175-
examples/misc/ftface_props.py: E501
176166
examples/misc/histogram_path.py: E402
177167
examples/misc/print_stdout_sgskip.py: E402
178-
examples/misc/svg_filter_line.py: E402, E501
179-
examples/misc/svg_filter_pie.py: E402, E501
168+
examples/misc/svg_filter_line.py: E402
169+
examples/misc/svg_filter_pie.py: E402
180170
examples/misc/table_demo.py: E201
181-
examples/mplot3d/voxels.py: E501
182-
examples/mplot3d/wire3d_zero_stride.py: E501
183171
examples/pie_and_polar_charts/bar_of_pie.py: E402
184172
examples/pie_and_polar_charts/nested_pie.py: E402
185173
examples/pie_and_polar_charts/pie_and_donut_labels.py: E402
@@ -190,7 +178,7 @@ per-file-ignores =
190178
examples/pie_and_polar_charts/polar_legend.py: E402
191179
examples/pie_and_polar_charts/polar_scatter.py: E402
192180
examples/pyplots/align_ylabels.py: E402
193-
examples/pyplots/annotate_transform.py: E228, E251, E402, E501
181+
examples/pyplots/annotate_transform.py: E228, E251, E402
194182
examples/pyplots/annotation_basic.py: E402
195183
examples/pyplots/annotation_polar.py: E231, E402
196184
examples/pyplots/auto_subplots_adjust.py: E231, E302, E402
@@ -216,13 +204,12 @@ per-file-ignores =
216204
examples/pyplots/whats_new_99_axes_grid.py: E402
217205
examples/pyplots/whats_new_99_mplot3d.py: E402
218206
examples/pyplots/whats_new_99_spines.py: E231, E402
219-
examples/recipes/placing_text_boxes.py: E501
220207
examples/scales/power_norm.py: E402
221208
examples/scales/scales.py: E402
222209
examples/shapes_and_collections/artist_reference.py: E402
223210
examples/shapes_and_collections/collections.py: E402
224211
examples/shapes_and_collections/compound_path.py: E402
225-
examples/shapes_and_collections/dolphin.py: E402, E501
212+
examples/shapes_and_collections/dolphin.py: E402
226213
examples/shapes_and_collections/donut.py: E402
227214
examples/shapes_and_collections/ellipse_collection.py: E402
228215
examples/shapes_and_collections/ellipse_demo.py: E402
@@ -231,17 +218,16 @@ per-file-ignores =
231218
examples/shapes_and_collections/line_collection.py: E402
232219
examples/shapes_and_collections/marker_path.py: E402
233220
examples/shapes_and_collections/patch_collection.py: E402
234-
examples/shapes_and_collections/path_patch.py: E402, E501
221+
examples/shapes_and_collections/path_patch.py: E402
235222
examples/shapes_and_collections/quad_bezier.py: E402
236223
examples/shapes_and_collections/scatter.py: E402
237224
examples/showcase/firefox.py: E501
238-
examples/specialty_plots/anscombe.py: E402, E501
225+
examples/specialty_plots/anscombe.py: E402
239226
examples/specialty_plots/radar_chart.py: E402
240-
examples/specialty_plots/sankey_basics.py: E402, E501
227+
examples/specialty_plots/sankey_basics.py: E402
241228
examples/specialty_plots/sankey_links.py: E402
242229
examples/specialty_plots/sankey_rankine.py: E402
243230
examples/specialty_plots/skewt.py: E402
244-
examples/statistics/boxplot_demo.py: E501
245231
examples/style_sheets/bmh.py: E501
246232
examples/style_sheets/ggplot.py: E501
247233
examples/style_sheets/plot_solarizedlight2.py: E501
@@ -253,8 +239,7 @@ per-file-ignores =
253239
examples/subplots_axes_and_figures/secondary_axis.py: E402
254240
examples/subplots_axes_and_figures/two_scales.py: E402
255241
examples/subplots_axes_and_figures/zoom_inset_axes.py: E402
256-
examples/tests/backend_driver_sgskip.py: E402, E501
257-
examples/text_labels_and_annotations/annotation_demo.py: E501
242+
examples/tests/backend_driver_sgskip.py: E402
258243
examples/text_labels_and_annotations/demo_text_rotation_mode.py: E402
259244
examples/text_labels_and_annotations/custom_legends.py: E402
260245
examples/text_labels_and_annotations/fancyarrow_demo.py: E402
@@ -265,24 +250,16 @@ per-file-ignores =
265250
examples/text_labels_and_annotations/mathtext_asarray.py: E402
266251
examples/text_labels_and_annotations/tex_demo.py: E402
267252
examples/text_labels_and_annotations/watermark_text.py: E402
268-
examples/ticks_and_spines/auto_ticks.py: E501
269253
examples/ticks_and_spines/date_concise_formatter.py: E402
270254
examples/user_interfaces/canvasagg.py: E402
271255
examples/user_interfaces/embedding_in_gtk3_panzoom_sgskip.py: E402
272256
examples/user_interfaces/embedding_in_gtk3_sgskip.py: E402
273257
examples/user_interfaces/embedding_in_qt_sgskip.py: E402
274-
examples/user_interfaces/embedding_in_wx2_sgskip.py: E501
275-
examples/user_interfaces/embedding_in_wx3_sgskip.py: E501
276-
examples/user_interfaces/embedding_in_wx4_sgskip.py: E501
277-
examples/user_interfaces/embedding_in_wx5_sgskip.py: E501
278-
examples/user_interfaces/embedding_webagg_sgskip.py: E501
279258
examples/user_interfaces/gtk_spreadsheet_sgskip.py: E402
280-
examples/user_interfaces/mathtext_wx_sgskip.py: E402, E501
259+
examples/user_interfaces/mathtext_wx_sgskip.py: E402
281260
examples/user_interfaces/mpl_with_glade3_sgskip.py: E402
282261
examples/user_interfaces/pylab_with_gtk_sgskip.py: E302, E402
283262
examples/user_interfaces/toolmanager_sgskip.py: E402
284263
examples/userdemo/connectionstyle_demo.py: E402
285264
examples/userdemo/custom_boxstyle01.py: E402
286265
examples/userdemo/pgf_preamble_sgskip.py: E402
287-
examples/userdemo/simple_annotate01.py: E501
288-
examples/widgets/rectangle_selector.py: E501

examples/event_handling/data_browser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def update(self):
7070
ax2.cla()
7171
ax2.plot(X[dataind])
7272

73-
ax2.text(0.05, 0.9, 'mu=%1.3f\nsigma=%1.3f' % (xs[dataind], ys[dataind]),
73+
ax2.text(0.05, 0.9, f'mu={xs[dataind]:1.3f}\nsigma={ys[dataind]:1.3f}',
7474
transform=ax2.transAxes, va='top')
7575
ax2.set_ylim(-0.5, 1.5)
7676
self.selected.set_visible(True)

examples/event_handling/viewlims.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,13 @@ def ax_update(self, ax):
6767
Z = md(-2., 0.5, -1.25, 1.25)
6868

6969
fig1, (ax1, ax2) = plt.subplots(1, 2)
70-
ax1.imshow(Z, origin='lower', extent=(md.x.min(), md.x.max(), md.y.min(), md.y.max()))
71-
ax2.imshow(Z, origin='lower', extent=(md.x.min(), md.x.max(), md.y.min(), md.y.max()))
70+
ax1.imshow(Z, origin='lower',
71+
extent=(md.x.min(), md.x.max(), md.y.min(), md.y.max()))
72+
ax2.imshow(Z, origin='lower',
73+
extent=(md.x.min(), md.x.max(), md.y.min(), md.y.max()))
7274

73-
rect = UpdatingRect([0, 0], 0, 0, facecolor='None', edgecolor='black', linewidth=1.0)
75+
rect = UpdatingRect(
76+
[0, 0], 0, 0, facecolor='none', edgecolor='black', linewidth=1.0)
7477
rect.set_bounds(*ax2.viewLim.bounds)
7578
ax1.add_patch(rect)
7679

examples/images_contours_and_fields/shading_example.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ def compare(z, cmap, ve=1):
7070
# References
7171
# """"""""""
7272
#
73-
# The use of the following functions, methods and classes is shown in this example:
73+
# The use of the following functions, methods and classes is shown in this
74+
# example:
7475

7576
import matplotlib
7677
matplotlib.colors.LightSource

examples/images_contours_and_fields/specgram_demo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
# - Pxx: the periodogram
3434
# - freqs: the frequency vector
3535
# - bins: the centers of the time bins
36-
# - im: the matplotlib.image.AxesImage instance representing the data in the plot
36+
# - im: the .image.AxesImage instance representing the data in the plot
3737
plt.show()
3838

3939
#############################################################################

examples/misc/anchored_artists.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
"""
1313

1414
from matplotlib import pyplot as plt
15-
from matplotlib.patches import Rectangle, Ellipse
15+
from matplotlib.lines import Line2D
16+
from matplotlib.patches import Ellipse
1617
from matplotlib.offsetbox import (
1718
AnchoredOffsetbox, AuxTransformBox, DrawingArea, TextArea, VPacker)
1819

@@ -91,7 +92,7 @@ def __init__(self, transform, size, label, loc,
9192
sep in points.
9293
"""
9394
self.size_bar = AuxTransformBox(transform)
94-
self.size_bar.add_artist(Rectangle((0, 0), size, 0, ec="black", lw=1.0))
95+
self.size_bar.add_artist(Line2D([0, size], [0, 0], color="black"))
9596

9697
self.txt_label = TextArea(label, minimumdescent=False)
9798

examples/misc/ftface_props.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,33 +19,33 @@
1919
os.path.join(matplotlib.get_data_path(),
2020
'fonts/ttf/DejaVuSans-Oblique.ttf'))
2121

22-
print('Num faces :', font.num_faces) # number of faces in file
23-
print('Num glyphs :', font.num_glyphs) # number of glyphs in the face
24-
print('Family name :', font.family_name) # face family name
25-
print('Style name :', font.style_name) # face style name
26-
print('PS name :', font.postscript_name) # the postscript name
27-
print('Num fixed :', font.num_fixed_sizes) # number of embedded bitmap in face
22+
print('Num faces: ', font.num_faces) # number of faces in file
23+
print('Num glyphs: ', font.num_glyphs) # number of glyphs in the face
24+
print('Family name:', font.family_name) # face family name
25+
print('Style name: ', font.style_name) # face style name
26+
print('PS name: ', font.postscript_name) # the postscript name
27+
print('Num fixed: ', font.num_fixed_sizes) # number of embedded bitmaps
2828

2929
# the following are only available if face.scalable
3030
if font.scalable:
3131
# the face global bounding box (xmin, ymin, xmax, ymax)
32-
print('Bbox :', font.bbox)
32+
print('Bbox: ', font.bbox)
3333
# number of font units covered by the EM
34-
print('EM :', font.units_per_EM)
34+
print('EM: ', font.units_per_EM)
3535
# the ascender in 26.6 units
36-
print('Ascender :', font.ascender)
36+
print('Ascender: ', font.ascender)
3737
# the descender in 26.6 units
38-
print('Descender :', font.descender)
38+
print('Descender: ', font.descender)
3939
# the height in 26.6 units
40-
print('Height :', font.height)
40+
print('Height: ', font.height)
4141
# maximum horizontal cursor advance
42-
print('Max adv width :', font.max_advance_width)
42+
print('Max adv width: ', font.max_advance_width)
4343
# same for vertical layout
44-
print('Max adv height :', font.max_advance_height)
44+
print('Max adv height: ', font.max_advance_height)
4545
# vertical position of the underline bar
46-
print('Underline pos :', font.underline_position)
46+
print('Underline pos: ', font.underline_position)
4747
# vertical thickness of the underline
48-
print('Underline thickness :', font.underline_thickness)
48+
print('Underline thickness:', font.underline_thickness)
4949

5050
for style in ('Italic',
5151
'Bold',
@@ -61,4 +61,4 @@
6161
'Glyph names',
6262
'External stream'):
6363
bitpos = getattr(ft, style.replace(' ', '_').upper()) - 1
64-
print('%-17s:' % style, bool(font.style_flags & (1 << bitpos)))
64+
print(f"{style+':':17}", bool(font.style_flags & (1 << bitpos)))

examples/misc/svg_filter_line.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@
6161

6262
# filter definition for a gaussian blur
6363
filter_def = """
64-
<defs xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'>
64+
<defs xmlns='http://www.w3.org/2000/svg'
65+
xmlns:xlink='http://www.w3.org/1999/xlink'>
6566
<filter id='dropshadow' height='1.2' width='1.2'>
6667
<feGaussianBlur result='blur' stdDeviation='3'/>
6768
</filter>

examples/misc/svg_filter_pie.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,19 +58,22 @@
5858
# that, Inkscape's exporting also may not support it.
5959

6060
filter_def = """
61-
<defs xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'>
61+
<defs xmlns='http://www.w3.org/2000/svg'
62+
xmlns:xlink='http://www.w3.org/1999/xlink'>
6263
<filter id='dropshadow' height='1.2' width='1.2'>
6364
<feGaussianBlur result='blur' stdDeviation='2'/>
6465
</filter>
6566
66-
<filter id='MyFilter' filterUnits='objectBoundingBox' x='0' y='0' width='1' height='1'>
67+
<filter id='MyFilter' filterUnits='objectBoundingBox'
68+
x='0' y='0' width='1' height='1'>
6769
<feGaussianBlur in='SourceAlpha' stdDeviation='4%' result='blur'/>
6870
<feOffset in='blur' dx='4%' dy='4%' result='offsetBlur'/>
6971
<feSpecularLighting in='blur' surfaceScale='5' specularConstant='.75'
7072
specularExponent='20' lighting-color='#bbbbbb' result='specOut'>
7173
<fePointLight x='-5000%' y='-10000%' z='20000%'/>
7274
</feSpecularLighting>
73-
<feComposite in='specOut' in2='SourceAlpha' operator='in' result='specOut'/>
75+
<feComposite in='specOut' in2='SourceAlpha'
76+
operator='in' result='specOut'/>
7477
<feComposite in='SourceGraphic' in2='specOut' operator='arithmetic'
7578
k1='0' k2='1' k3='1' k4='0'/>
7679
</filter>

examples/mplot3d/voxels.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
# prepare some coordinates
1414
x, y, z = np.indices((8, 8, 8))
1515

16-
# draw cuboids in the top left and bottom right corners, and a link between them
16+
# draw cuboids in the top left and bottom right corners, and a link between
17+
# them
1718
cube1 = (x < 3) & (y < 3) & (z < 3)
1819
cube2 = (x >= 5) & (y >= 5) & (z >= 5)
1920
link = abs(x - y) + abs(y - z) + abs(z - x) <= 2

examples/mplot3d/wire3d_zero_stride.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
import matplotlib.pyplot as plt
1212

1313

14-
fig, [ax1, ax2] = plt.subplots(2, 1, figsize=(8, 12), subplot_kw={'projection': '3d'})
14+
fig, (ax1, ax2) = plt.subplots(
15+
2, 1, figsize=(8, 12), subplot_kw={'projection': '3d'})
1516

1617
# Get the test data
1718
X, Y, Z = axes3d.get_test_data(0.05)

examples/pyplots/annotate_transform.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
For a complete overview of the annotation capabilities, also see the
88
:doc:`annotation tutorial</tutorials/text/annotations>`.
99
"""
10+
1011
import numpy as np
1112
import matplotlib.pyplot as plt
1213

@@ -23,21 +24,20 @@
2324

2425
bbox = dict(boxstyle="round", fc="0.8")
2526
arrowprops = dict(
26-
arrowstyle = "->",
27-
connectionstyle = "angle,angleA=0,angleB=90,rad=10")
27+
arrowstyle="->",
28+
connectionstyle="angle,angleA=0,angleB=90,rad=10")
2829

2930
offset = 72
30-
ax.annotate('data = (%.1f, %.1f)'%(xdata, ydata),
31-
(xdata, ydata), xytext=(-2*offset, offset), textcoords='offset points',
32-
bbox=bbox, arrowprops=arrowprops)
33-
34-
35-
disp = ax.annotate('display = (%.1f, %.1f)'%(xdisplay, ydisplay),
36-
(xdisplay, ydisplay), xytext=(0.5*offset, -offset),
37-
xycoords='figure pixels',
38-
textcoords='offset points',
39-
bbox=bbox, arrowprops=arrowprops)
40-
31+
ax.annotate(
32+
f'data = ({xdata:.1f}, {ydata:.1f})',
33+
(xdata, ydata),
34+
xytext=(-2*offset, offset), textcoords='offset points',
35+
bbox=bbox, arrowprops=arrowprops)
36+
ax.annotate(
37+
f'display = ({xdisplay:.1f}, {ydisplay:.1f})',
38+
xy=(xdisplay, ydisplay), xycoords='figure pixels',
39+
xytext=(0.5*offset, -offset), textcoords='offset points',
40+
bbox=bbox, arrowprops=arrowprops)
4141

4242
plt.show()
4343

examples/shapes_and_collections/dolphin.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@
3838
plt.plot(x, y, 'o', color=(0.9, 0.9, 1.0), alpha=0.8)
3939

4040
# Dolphin from OpenClipart library by Andy Fitzsimon
41-
# <cc:License rdf:about="http://web.resource.org/cc/PublicDomain">
42-
# <cc:permits rdf:resource="http://web.resource.org/cc/Reproduction"/>
43-
# <cc:permits rdf:resource="http://web.resource.org/cc/Distribution"/>
44-
# <cc:permits rdf:resource="http://web.resource.org/cc/DerivativeWorks"/>
45-
# </cc:License>
41+
# <cc:License rdf:about="http://web.resource.org/cc/PublicDomain">
42+
# <cc:permits rdf:resource="http://web.resource.org/cc/Reproduction"/>
43+
# <cc:permits rdf:resource="http://web.resource.org/cc/Distribution"/>
44+
# <cc:permits rdf:resource="http://web.resource.org/cc/DerivativeWorks"/>
45+
# </cc:License>
4646

4747
dolphin = """
4848
M -0.59739425,160.18173 C -0.62740401,160.18885 -0.57867129,160.11183

0 commit comments

Comments
 (0)