8000 Merge pull request #20119 from QuLogic/flake8-examples · matplotlib/matplotlib@363105b · GitHub
[go: up one dir, main page]

Skip to content

Commit 363105b

Browse files
authored
Merge pull request #20119 from QuLogic/flake8-examples
Cleanup flake8 exceptions for examples
2 parents 8ac6bcb + e6fdc1f commit 363105b

25 files changed

+181
-489
lines changed

.flake8

Lines changed: 4 additions & 163 deletions
Original file line numberDiff line numberDiff line change
@@ -110,179 +110,20 @@ per-file-ignores =
110110
tutorials/toolkits/axisartist.py: E501
111111

112112
examples/animation/frame_grabbing_sgskip.py: E402
113-
examples/axes_grid1/inset_locator_demo.py: E402
114-
examples/axes_grid1/scatter_hist_locatable_axes.py: E402
115-
examples/axisartist/demo_curvelinear_grid.py: E402
116-
examples/color/color_by_yvalue.py: E402
117-
examples/color/color_cycle_default.py: E402
118-
examples/color/color_cycler.py: E402
119-
examples/color/color_demo.py: E402
120-
examples/color/colorbar_basics.py: E402
121-
examples/color/colormap_reference.py: E402
122-
examples/color/custom_cmap.py: E402
123-
examples/color/named_colors.py: E402
124-
examples/images_contours_and_fields/affine_image.py: E402
125-
examples/images_contours_and_fields/barb_demo.py: E402
126-
examples/images_contours_and_fields/barcode_demo.py: E402
127-
examples/images_contours_and_fields/contour_corner_mask.py: E402
128-
examples/images_contours_and_fields/contour_demo.py: E402
129-
examples/images_contours_and_fields/contour_image.py: E402
130-
examples/images_contours_and_fields/contourf_demo.py: E402
131-
examples/images_contours_and_fields/contourf_hatching.py: E402
132-
examples/images_contours_and_fields/contourf_log.py: E402
133-
examples/images_contours_and_fields/demo_bboximage.py: E402
134-
examples/images_contours_and_fields/image_antialiasing.py: E402
135-
examples/images_contours_and_fields/image_clip_path.py: E402
136-
examples/images_contours_and_fields/image_demo.py: E402
137-
examples/images_contours_and_fields/image_masked.py: E402
138-
examples/images_contours_and_fields/image_transparency_blend.py: E402
139-
examples/images_contours_and_fields/image_zcoord.py: E402
140-
examples/images_contours_and_fields/interpolation_methods.py: E402
141-
examples/images_contours_and_fields/irregulardatagrid.py: E402
142-
examples/images_contours_and_fields/layer_images.py: E402
143-
examples/images_contours_and_fields/matshow.py: E402
144-
examples/images_contours_and_fields/multi_image.py: E402
145-
examples/images_contours_and_fields/pcolor_demo.py: E402
146-
examples/images_contours_and_fields/plot_streamplot.py: E402
147-
examples/images_contours_and_fields/quadmesh_demo.py: E402
148-
examples/images_contours_and_fields/quiver_demo.py: E402
149-
examples/images_contours_and_fields/quiver_simple_demo.py: E402
150-
examples/images_contours_and_fields/shading_example.py: E402
151-
examples/images_contours_and_fields/specgram_demo.py: E402
152-
examples/images_contours_and_fields/spy_demos.py: E402
153-
examples/images_contours_and_fields/tricontour_demo.py: E201, E402
154-
examples/images_contours_and_fields/tricontour_smooth_delaunay.py: E402
155-
examples/images_contours_and_fields/tricontour_smooth_user.py: E402
156-
examples/images_contours_and_fields/trigradient_demo.py: E402
157-
examples/images_contours_and_fields/triinterp_demo.py: E402
158-
examples/images_contours_and_fields/tripcolor_demo.py: E201, E402
159-
examples/images_contours_and_fields/triplot_demo.py: E201, E402
160-
examples/images_contours_and_fields/watermark_image.py: E402
161-
examples/lines_bars_and_markers/curve_error_band.py: E402
162-
examples/lines_bars_and_markers/errorbar_limits_simple.py: E402
163-
examples/lines_bars_and_markers/fill.py: E402
164-
examples/lines_bars_and_markers/fill_between_demo.py: E402
165-
examples/lines_bars_and_markers/filled_step.py: E402
166-
examples/lines_bars_and_markers/stairs_demo.py: E402
167-
examples/lines_bars_and_markers/horizontal_barchart_distribution.py: E402
168-
examples/lines_bars_and_markers/joinstyle.py: E402
169-
examples/lines_bars_and_markers/scatter_hist.py: E402
170-
examples/lines_bars_and_markers/scatter_piecharts.py: E402
171-
examples/lines_bars_and_markers/scatter_with_legend.py: E402
172-
examples/lines_bars_and_markers/span_regions.py: E402
173-
examples/lines_bars_and_markers/stem_plot.py: E402
174-
examples/lines_bars_and_markers/step_demo.py: E402
175-
examples/lines_bars_and_markers/timeline.py: E402
176-
examples/lines_bars_and_markers/xcorr_acorr_demo.py: E402
177-
examples/misc/agg_buffer.py: E402
178-
examples/misc/histogram_path.py: E402
113+
examples/images_contours_and_fields/tricontour_demo.py: E201
114+
examples/images_contours_and_fields/tripcolor_demo.py: E201
115+
examples/images_contours_and_fields/triplot_demo.py: E201
179116
examples/misc/print_stdout_sgskip.py: E402
180-
examples/misc/rasterization_demo.py: E402
181-
examples/misc/svg_filter_line.py: E402
182-
examples/misc/svg_filter_pie.py: E402
183117
examples/misc/table_demo.py: E201
184-
examples/mplot3d/surface3d.py: E402
185-
examples/pie_and_polar_charts/bar_of_pie.py: E402
186-
examples/pie_and_polar_charts/nested_pie.py: E402
187-
examples/pie_and_polar_charts/pie_and_donut_labels.py: E402
188-
examples/pie_and_polar_charts/pie_demo2.py: E402
189-
examples/pie_and_polar_charts/pie_features.py: E402
190-
examples/pie_and_polar_charts/polar_bar.py: E402
191-
examples/pie_and_polar_charts/polar_demo.py: E402
192-
examples/pie_and_polar_charts/polar_legend.py: E402
193-
examples/pie_and_polar_charts/polar_scatter.py: E402
194-
examples/pyplots/align_ylabels.py: E402
195-
examples/pyplots/annotate_transform.py: E251, E402
196-
examples/pyplots/annotation_basic.py: E402
197-
examples/pyplots/annot 10000 ation_polar.py: E402
198-
examples/pyplots/auto_subplots_adjust.py: E302, E402
199-
examples/pyplots/axline.py: E402
200-
examples/pyplots/boxplot_demo_pyplot.py: E402
201-
examples/pyplots/dollar_ticks.py: E402
202-
examples/pyplots/fig_axes_customize_simple.py: E402
203-
examples/pyplots/fig_axes_labels_simple.py: E402
204-
examples/pyplots/fig_x.py: E402
205-
examples/pyplots/pyplot_formatstr.py: E402
206-
examples/pyplots/pyplot_mathtext.py: E402
207-
examples/pyplots/pyplot_scales.py: E402
208-
examples/pyplots/pyplot_simple.py: E402
209-
examples/pyplots/pyplot_text.py: E402
210-
examples/pyplots/pyplot_three.py: E402
211-
examples/pyplots/pyplot_two_subplots.py: E402
212-
examples/pyplots/text_commands.py: E402
213-
examples/pyplots/text_layout.py: E402
214-
examples/pyplots/whats_new_1_subplot3d.py: E402
215-
examples/pyplots/whats_new_98_4_fill_between.py: E402
216-
examples/pyplots/whats_new_98_4_legend.py: E402
217-
examples/pyplots/whats_new_99_axes_grid.py: E402
218-
examples/pyplots/whats_new_99_mplot3d.py: E402
219-
examples/pyplots/whats_new_99_spines.py: E402
220-
examples/scales/power_norm.py: E402
221-
examples/scales/scales.py: E402
222-
examples/shapes_and_collections/artist_reference.py: E402
223-
examples/shapes_and_collections/collections.py: E402
224-
examples/shapes_and_collections/compound_path.py: E402
225-
examples/shapes_and_collections/dolphin.py: E402
226-
examples/shapes_and_collections/donut.py: E402
227-
examples/shapes_and_collections/ellipse_collection.py: E402
228-
examples/shapes_and_collections/ellipse_demo.py: E402
229-
examples/shapes_and_collections/fancybox_demo.py: E402
230-
examples/shapes_and_collections/hatch_demo.py: E402
231-
examples/shapes_and_collections/hatch_style_reference.py: E402
232-
examples/shapes_and_collections/line_collection.py: E402
233-
examples/shapes_and_collections/marker_path.py: E402
234-
examples/shapes_and_collections/patch_collection.py: E402
235-
examples/shapes_and_collections/path_patch.py: E402
236-
examples/shapes_and_collections/quad_bezier.py: E402
237-
examples/shapes_and_collections/scatter.py: E402
238-
examples/showcase/anatomy.py: E402
239-
examples/showcase/bachelors_degrees_by_gender.py: E402
240-
examples/showcase/firefox.py: E501
241-
examples/specialty_plots/anscombe.py: E402
242-
examples/specialty_plots/radar_chart.py: E402
243-
examples/specialty_plots/sankey_basics.py: E402
244-
examples/specialty_plots/sankey_links.py: E402
245-
examples/specialty_plots/sankey_rankine.py: E402
246-
examples/specialty_plots/skewt.py: E402
247118
examples/style_sheets/bmh.py: E501
248-
examples/style_sheets/ggplot.py: E501
249119
examples/style_sheets/plot_solarizedlight2.py: E501
250-
examples/subplots_axes_and_figures/axes_margins.py: E402
251-
examples/subplots_axes_and_figures/axes_zoom_effect.py: E402
252-
examples/subplots_axes_and_figures/custom_figure_class.py: E402
253120
examples/subplots_axes_and_figures/demo_constrained_layout.py: E402
254-
examples/subplots_axes_and_figures/demo_tight_layout.py: E402, E501
255-
examples/subplots_axes_and_figures/figure_size_units.py: E402
256-
examples/subplots_axes_and_figures/secondary_axis.py: E402
257-
examples/subplots_axes_and_figures/two_scales.py: E402
258-
examples/subplots_axes_and_figures/zoom_inset_axes.py: E402
259-
examples/text_labels_and_annotations/date_index_formatter.py: E402
260-
examples/text_labels_and_annotations/demo_text_rotation_mode.py: E402
261121
examples/text_labels_and_annotations/custom_legends.py: E402
262-
examples/text_labels_and_annotations/fancyarrow_demo.py: E402
263-
examples/text_labels_and_annotations/font_family_rc_sgskip.py: E402
264-
examples/text_labels_and_annotations/font_file.py: E402
265-
examples/text_labels_and_annotations/legend.py: E402
266-
examples/text_labels_and_annotations/line_with_text.py: E402
267-
examples/text_labels_and_annotations/mathtext_asarray.py: E402
268-
examples/text_labels_and_annotations/tex_demo.py: E402
269-
examples/text_labels_and_annotations/watermark_text.py: E402
270-
examples/ticks_and_spines/custom_ticker1.py: E402
271122
examples/ticks_and_spines/date_concise_formatter.py: E402
272-
examples/ticks_and_spines/major_minor_demo.py: E402
273-
examples/ticks_and_spines/tick-formatters.py: E402
274-
examples/ticks_and_spines/tick_labels_from_values.py: E402
275-
examples/user_interfaces/canvasagg.py: E402
276123
examples/user_interfaces/embedding_in_gtk3_panzoom_sgskip.py: E402
277124
examples/user_interfaces/embedding_in_gtk3_sgskip.py: E402
278-
examples/user_interfaces/embedding_in_qt_sgskip.py: E402
279125
examples/user_interfaces/gtk_spreadsheet_sgskip.py: E402
280-
examples/user_interfaces/mathtext_wx_sgskip.py: E402
281126
examples/user_interfaces/mpl_with_glade3_sgskip.py: E402
282-
examples/user_interfaces/pylab_with_gtk_sgskip.py: E302, E402
127+
examples/user_interfaces/pylab_with_gtk_sgskip.py: E402
283128
examples/user_interfaces/toolmanager_sgskip.py: E402
284-
examples/userdemo/connectionstyle_demo.py: E402
285-
examples/userdemo/custom_boxstyle01.py: E402
286129
examples/userdemo/pgf_preamble_sgskip.py: E402
287-
examples/widgets/*.py: E402
288-
examples/statistics/*.py: E402

doc/users/prev_whats_new/whats_new_0.98.4.rst

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,18 @@ multiple columns and rows, as well as fancy box drawing. See
3030
:func:`~matplotlib.pyplot.legend` and
3131
:class:`matplotlib.legend.Legend`.
3232

33-
.. figure:: ../../gallery/pyplots/images/sphx_glr_whats_new_98_4_legend_001.png
34-
:target: ../../gallery/pyplots/whats_new_98_4_legend.html
35-
:align: center
36-
:scale: 50
33+
.. plot::
34+
35+
ax = plt.subplot()
36+
t1 = np.arange(0.0, 1.0, 0.01)
37+
for n in [1, 2, 3, 4]:
38+
plt.plot(t1, t1**n, label=f"n={n}")
39+
40+
leg = plt.legend(loc='best', ncol=2, mode="expand", shadow=True, fancybox=True)
41+
leg.get_frame().set_alpha(0.5)
42+
43+
plt.show()
3744

38-
What's New 98 4 Legend
3945

4046
.. _fancy-annotations:
4147

@@ -145,12 +151,20 @@ can pass an *x* array and a *ylower* and *yupper* array to fill
145151
between, and an optional *where* argument which is a logical mask
146152
where you want to do the filling.
147153

148-
.. figure:: ../../gallery/pyplots/images/sphx_glr_whats_new_98_4_fill_between_001.png
149-
:target: ../../gallery/pyplots/whats_new_98_4_fill_between.html
150-
:align: center
151-
:scale: 50
154+
.. plot::
155+
156+
x = np.arange(-5, 5, 0.01)
157+
y1 = -5*x*x + x + 10
158+
y2 = 5*x*x + x
159+
160+
fig, ax = plt.subplots()
161+
ax.plot(x, y1, x, y2, color='black')
162+
ax.fill_between(x, y1, y2, where=(y2 > y1), facecolor='yellow', alpha=0.5)
163+
ax.fill_between(x, y1, y2, where=(y2 <= y1), facecolor='red', alpha=0.5)
164+
ax.set_title('Fill Between')
165+
166+
plt.show()
152167

153-
What's New 98 4 Fill Between
154168

155169
Lots more
156170
---------

doc/users/prev_whats_new/whats_new_0.99.rst

Lines changed: 101 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,29 @@ working with paths and transformations: :doc:`/tutorials/advanced/path_tutorial`
2222
mplot3d
2323
--------
2424

25-
2625
Reinier Heeres has ported John Porter's mplot3d over to the new
2726
matplotlib transformations framework, and it is now available as a
2827
toolkit mpl_toolkits.mplot3d (which now comes standard with all mpl
2928
installs). See :ref:`mplot3d-examples-index` and
3029
:ref:`toolkit_mplot3d-tutorial`
3130

32-
.. figure:: ../../gallery/pyplots/images/sphx_glr_whats_new_99_mplot3d_001.png
33-
:target: ../../gallery/pyplots/whats_new_99_mplot3d.html
34-
:align: center
35-
:scale: 50
31+
.. plot::
32+
33+
from matplotlib import cm
34+
from mpl_toolkits.mplot3d import Axes3D
35+
36+
X = np.arange(-5, 5, 0.25)
37+
Y = np.arange(-5, 5, 0.25)
38+
X, Y = np.meshgrid(X, Y)
39+
R = np.sqrt(X**2 + Y**2)
40+
Z = np.sin(R)
41+
42+
fig = plt.figure()
43+
ax = Axes3D(fig, auto_add_to_figure=False)
44+
fig.add_axes(ax)
45+
ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=cm.viridis)
3646

37-
What's New 99 Mplot3d
47+
plt.show()
3848

3949
.. _whats-new-axes-grid:
4050

@@ -48,12 +58,49 @@ new mpl installs. See :ref:`axes_grid1-examples-index`,
4858
:ref:`axisartist-examples-index`, :ref:`axes_grid1_users-guide-index` and
4959
:ref:`axisartist_users-guide-index`
5060

51-
.. figure:: ../../gallery/pyplots/images/sphx_glr_whats_new_99_axes_grid_001.png
52-
:target: ../../gallery/pyplots/whats_new_99_axes_grid.html
53-
:align: center
54-
:scale: 50
61+
.. plot::
62+
63+
from mpl_toolkits.axes_grid1.axes_rgb import RGBAxes
64+
65+
66+
def get_demo_image():
67+
# prepare image
68+
delta = 0.5
69+
70+
extent = (-3, 4, -4, 3)
71+
x = np.arange(-3.0, 4.001, delta)
72+
y = np.arange(-4.0, 3.001, delta)
73+
X, Y = np.meshgrid(x, y)
74+
Z1 = np.exp(-X**2 - Y**2)
75+
Z2 = np.exp(-(X - 1)**2 - (Y - 1)**2)
76+
Z = (Z1 - Z2) * 2
77+
78+
return Z, extent
79+
80+
81+
def get_rgb():
82+
Z, extent = get_demo_image()
83+
84+
Z[Z < 0] = 0.
85+
Z = Z / Z.max()
86+
87+
R = Z[:13, :13]
88+
G = Z[2:, 2:]
89+
B = Z[:13, 2:]
90+
91+
return R, G, B
5592

56-
What's New 99 Axes Grid
93+
94+
fig = plt.figure()
95+
ax = RGBAxes(fig, [0.1, 0.1, 0.8, 0.8])
96+
97+
r, g, b = get_rgb()
98+
ax.imshow_rgb(r, g, b, origin="lower")
99+
100+
ax.RGB.set_xlim(0., 9.5)
101+
ax.RGB.set_ylim(0.9, 10.6)
102+
103+
plt.show()
57104

58105
.. _whats-new-spine:
59106

@@ -68,9 +115,47 @@ well as "detach" the spine to offset it away from the data. See
68115
:doc:`/gallery/ticks_and_spines/spine_placement_demo` and
69116
:class:`matplotlib.spines.Spine`.
70117

71-
.. figure:: ../../gallery/pyplots/images/sphx_glr_whats_new_99_spines_001.png
72-
:target: ../../gallery/pyplots/whats_new_99_spines.html
73-
:align: center
74-
:scale: 50
118+
.. plot::
119+
120+
def adjust_spines(ax, spines):
121+
for loc, spine in ax.spines.items():
122+
if loc in spines:
123+
spine.set_position(('outward', 10)) # outward by 10 points
124+
else:
125+
spine.set_color('none') # don't draw spine
126+
127+
# turn off ticks where there is no spine
128+
if 'left' in spines:
129+
ax.yaxis.set_ticks_position('left')
130+
else:
131+
# no yaxis ticks
132+
ax.yaxis.set_ticks([])
133+
134+
if 'bottom' in spines:
135+
ax.xaxis.set_ticks_position('bottom')
136+
else:
137+
# no xaxis ticks
138+
ax.xaxis.set_ticks([])
139+
140+
fig = plt.figure()
141+
142+
x = np.linspace(0, 2*np.pi, 100)
143+
y = 2*np.sin(x)
144+
145+
ax = fig.add_subplot(2, 2, 1)
146+
ax.plot(x, y)
147+
adjust_spines(ax, ['left'])
148+
149+
ax = fig.add_subplot(2, 2, 2)
150+
ax.plot(x, y)
151+
adjust_spines(ax, [])
152+
153+
ax = fig.add_subplot(2, 2, 3)
154+
ax.plot(x, y)
155+
adjust_spines(ax, ['left', 'bottom'])
156+
157+
ax = fig.add_subplot(2, 2, 4)
158+
ax.plot(x, y)
159+
adjust_spines(ax, ['bottom'])
75160

76-
What's New 99 Spines
161+
plt.show()

0 commit comments

Comments
 (0)
0