Skip to content

Cleanup flake8 exceptions for examples #20119

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
167 changes: 4 additions & 163 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -112,179 +112,20 @@ per-file-ignores =
tutorials/toolkits/axisartist.py: E501

examples/animation/frame_grabbing_sgskip.py: E402
examples/axes_grid1/inset_locator_demo.py: E402
examples/axes_grid1/scatter_hist_locatable_axes.py: E402
examples/axisartist/demo_curvelinear_grid.py: E402
examples/color/color_by_yvalue.py: E402
examples/color/color_cycle_default.py: E402
examples/color/color_cycler.py: E402
examples/color/color_demo.py: E402
examples/color/colorbar_basics.py: E402
examples/color/colormap_reference.py: E402
examples/color/custom_cmap.py: E402
examples/color/named_colors.py: E402
examples/images_contours_and_fields/affine_image.py: E402
examples/images_contours_and_fields/barb_demo.py: E402
examples/images_contours_and_fields/barcode_demo.py: E402
examples/images_contours_and_fields/contour_corner_mask.py: E402
examples/images_contours_and_fields/contour_demo.py: E402
examples/images_contours_and_fields/contour_image.py: E402
examples/images_contours_and_fields/contourf_demo.py: E402
examples/images_contours_and_fields/contourf_hatching.py: E402
examples/images_contours_and_fields/contourf_log.py: E402
examples/images_contours_and_fields/demo_bboximage.py: E402
examples/images_contours_and_fields/image_antialiasing.py: E402
examples/images_contours_and_fields/image_clip_path.py: E402
examples/images_contours_and_fields/image_demo.py: E402
examples/images_contours_and_fields/image_masked.py: E402
examples/images_contours_and_fields/image_transparency_blend.py: E402
examples/images_contours_and_fields/image_zcoord.py: E402
examples/images_contours_and_fields/interpolation_methods.py: E402
examples/images_contours_and_fields/irregulardatagrid.py: E402
examples/images_contours_and_fields/layer_images.py: E402
examples/images_contours_and_fields/matshow.py: E402
examples/images_contours_and_fields/multi_image.py: E402
examples/images_contours_and_fields/pcolor_demo.py: E402
examples/images_contours_and_fields/plot_streamplot.py: E402
examples/images_contours_and_fields/quadmesh_demo.py: E402
examples/images_contours_and_fields/quiver_demo.py: E402
examples/images_contours_and_fields/quiver_simple_demo.py: E402
examples/images_contours_and_fields/shading_example.py: E402
examples/images_contours_and_fields/specgram_demo.py: E402
examples/images_contours_and_fields/spy_demos.py: E402
examples/images_contours_and_fields/tricontour_demo.py: E201, E402
examples/images_contours_and_fields/tricontour_smooth_delaunay.py: E402
examples/images_contours_and_fields/tricontour_smooth_user.py: E402
examples/images_contours_and_fields/trigradient_demo.py: E402
examples/images_contours_and_fields/triinterp_demo.py: E402
examples/images_contours_and_fields/tripcolor_demo.py: E201, E402
examples/images_contours_and_fields/triplot_demo.py: E201, E402
examples/images_contours_and_fields/watermark_image.py: E402
examples/lines_bars_and_markers/curve_error_band.py: E402
examples/lines_bars_and_markers/errorbar_limits_simple.py: E402
examples/lines_bars_and_markers/fill.py: E402
examples/lines_bars_and_markers/fill_between_demo.py: E402
examples/lines_bars_and_markers/filled_step.py: E402
examples/lines_bars_and_markers/stairs_demo.py: E402
examples/lines_bars_and_markers/horizontal_barchart_distribution.py: E402
examples/lines_bars_and_markers/joinstyle.py: E402
examples/lines_bars_and_markers/scatter_hist.py: E402
examples/lines_bars_and_markers/scatter_piecharts.py: E402
examples/lines_bars_and_markers/scatter_with_legend.py: E402
examples/lines_bars_and_markers/span_regions.py: E402
examples/lines_bars_and_markers/stem_plot.py: E402
examples/lines_bars_and_markers/step_demo.py: E402
examples/lines_bars_and_markers/timeline.py: E402
examples/lines_bars_and_markers/xcorr_acorr_demo.py: E402
examples/misc/agg_buffer.py: E402
examples/misc/histogram_path.py: E402
examples/images_contours_and_fields/tricontour_demo.py: E201
examples/images_contours_and_fields/tripcolor_demo.py: E201
examples/images_contours_and_fields/triplot_demo.py: E201
examples/misc/print_stdout_sgskip.py: E402
examples/misc/rasterization_demo.py: E402
examples/misc/svg_filter_line.py: E402
examples/misc/svg_filter_pie.py: E402
examples/misc/table_demo.py: E201
examples/mplot3d/surface3d.py: E402
examples/pie_and_polar_charts/bar_of_pie.py: E402
examples/pie_and_polar_charts/nested_pie.py: E402
examples/pie_and_polar_charts/pie_and_donut_labels.py: E402
examples/pie_and_polar_charts/pie_demo2.py: E402
examples/pie_and_polar_charts/pie_features.py: E402
examples/pie_and_polar_charts/polar_bar.py: E402
examples/pie_and_polar_charts/polar_demo.py: E402
examples/pie_and_polar_charts/polar_legend.py: E402
examples/pie_and_polar_charts/polar_scatter.py: E402
examples/pyplots/align_ylabels.py: E402
examples/pyplots/annotate_transform.py: E251, E402
examples/pyplots/annotation_basic.py: E402
examples/pyplots/annotation_polar.py: E402
examples/pyplots/auto_subplots_adjust.py: E302, E402
examples/pyplots/axline.py: E402
examples/pyplots/boxplot_demo_pyplot.py: E402
examples/pyplots/dollar_ticks.py: E402
examples/pyplots/fig_axes_customize_simple.py: E402
examples/pyplots/fig_axes_labels_simple.py: E402
examples/pyplots/fig_x.py: E402
examples/pyplots/pyplot_formatstr.py: E402
examples/pyplots/pyplot_mathtext.py: E402
examples/pyplots/pyplot_scales.py: E402
examples/pyplots/pyplot_simple.py: E402
examples/pyplots/pyplot_text.py: E402
examples/pyplots/pyplot_three.py: E402
examples/pyplots/pyplot_two_subplots.py: E402
examples/pyplots/text_commands.py: E402
examples/pyplots/text_layout.py: E402
examples/pyplots/whats_new_1_subplot3d.py: E402
examples/pyplots/whats_new_98_4_fill_between.py: E402
examples/pyplots/whats_new_98_4_legend.py: E402
examples/pyplots/whats_new_99_axes_grid.py: E402
examples/pyplots/whats_new_99_mplot3d.py: E402
examples/pyplots/whats_new_99_spines.py: E402
examples/scales/power_norm.py: E402
examples/scales/scales.py: E402
examples/shapes_and_collections/artist_reference.py: E402
examples/shapes_and_collections/collections.py: E402
examples/shapes_and_collections/compound_path.py: E402
examples/shapes_and_collections/dolphin.py: E402
examples/shapes_and_collections/donut.py: E402
examples/shapes_and_collections/ellipse_collection.py: E402
examples/shapes_and_collections/ellipse_demo.py: E402
examples/shapes_and_collections/fancybox_demo.py: E402
examples/shapes_and_collections/hatch_demo.py: E402
examples/shapes_and_collections/hatch_style_reference.py: E402
examples/shapes_and_collections/line_collection.py: E402
examples/shapes_and_collections/marker_path.py: E402
examples/shapes_and_collections/patch_collection.py: E402
examples/shapes_and_collections/path_patch.py: E402
examples/shapes_and_collections/quad_bezier.py: E402
examples/shapes_and_collections/scatter.py: E402
examples/showcase/anatomy.py: E402
examples/showcase/bachelors_degrees_by_gender.py: E402
examples/showcase/firefox.py: E501
examples/specialty_plots/anscombe.py: E402
examples/specialty_plots/radar_chart.py: E402
examples/specialty_plots/sankey_basics.py: E402
examples/specialty_plots/sankey_links.py: E402
examples/specialty_plots/sankey_rankine.py: E402
examples/specialty_plots/skewt.py: E402
examples/style_sheets/bmh.py: E501
examples/style_sheets/ggplot.py: E501
examples/style_sheets/plot_solarizedlight2.py: E501
examples/subplots_axes_and_figures/axes_margins.py: E402
examples/subplots_axes_and_figures/axes_zoom_effect.py: E402
examples/subplots_axes_and_figures/custom_figure_class.py: E402
examples/subplots_axes_and_figures/demo_constrained_layout.py: E402
examples/subplots_axes_and_figures/demo_tight_layout.py: E402, E501
examples/subplots_axes_and_figures/figure_size_units.py: E402
examples/subplots_axes_and_figures/secondary_axis.py: E402
examples/subplots_axes_and_figures/two_scales.py: E402
examples/subplots_axes_and_figures/zoom_inset_axes.py: E402
examples/text_labels_and_annotations/date_index_formatter.py: E402
examples/text_labels_and_annotations/demo_text_rotation_mode.py: E402
examples/text_labels_and_annotations/custom_legends.py: E402
examples/text_labels_and_annotations/fancyarrow_demo.py: E402
examples/text_labels_and_annotations/font_family_rc_sgskip.py: E402
examples/text_labels_and_annotations/font_file.py: E402
examples/text_labels_and_annotations/legend.py: E402
examples/text_labels_and_annotations/line_with_text.py: E402
examples/text_labels_and_annotations/mathtext_asarray.py: E402
examples/text_labels_and_annotations/tex_demo.py: E402
examples/text_labels_and_annotations/watermark_text.py: E402
examples/ticks_and_spines/custom_ticker1.py: E402
examples/ticks_and_spines/date_concise_formatter.py: E402
examples/ticks_and_spines/major_minor_demo.py: E402
examples/ticks_and_spines/tick-formatters.py: E402
examples/ticks_and_spines/tick_labels_from_values.py: E402
examples/user_interfaces/canvasagg.py: E402
examples/user_interfaces/embedding_in_gtk3_panzoom_sgskip.py: E402
examples/user_interfaces/embedding_in_gtk3_sgskip.py: E402
examples/user_interfaces/embedding_in_qt_sgskip.py: E402
examples/user_interfaces/gtk_spreadsheet_sgskip.py: E402
examples/user_interfaces/mathtext_wx_sgskip.py: E402
examples/user_interfaces/mpl_with_glade3_sgskip.py: E402
examples/user_interfaces/pylab_with_gtk_sgskip.py: E302, E402
examples/user_interfaces/pylab_with_gtk_sgskip.py: E402
examples/user_interfaces/toolmanager_sgskip.py: E402
examples/userdemo/connectionstyle_demo.py: E402
examples/userdemo/custom_boxstyle01.py: E402
examples/userdemo/pgf_preamble_sgskip.py: E402
examples/widgets/*.py: E402
examples/statistics/*.py: E402
34 changes: 24 additions & 10 deletions doc/users/prev_whats_new/whats_new_0.98.4.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,18 @@ multiple columns and rows, as well as fancy box drawing. See
:func:`~matplotlib.pyplot.legend` and
:class:`matplotlib.legend.Legend`.

.. figure:: ../../gallery/pyplots/images/sphx_glr_whats_new_98_4_legend_001.png
:target: ../../gallery/pyplots/whats_new_98_4_legend.html
:align: center
:scale: 50
.. plot::

ax = plt.subplot()
t1 = np.arange(0.0, 1.0, 0.01)
for n in [1, 2, 3, 4]:
plt.plot(t1, t1**n, label=f"n={n}")

leg = plt.legend(loc='best', ncol=2, mode="expand", shadow=True, fancybox=True)
leg.get_frame().set_alpha(0.5)

plt.show()

What's New 98 4 Legend

.. _fancy-annotations:

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

.. figure:: ../../gallery/pyplots/images/sphx_glr_whats_new_98_4_fill_between_001.png
:target: ../../gallery/pyplots/whats_new_98_4_fill_between.html
:align: center
:scale: 50
.. plot::

x = np.arange(-5, 5, 0.01)
y1 = -5*x*x + x + 10
y2 = 5*x*x + x

fig, ax = plt.subplots()
ax.plot(x, y1, x, y2, color='black')
ax.fill_between(x, y1, y2, where=(y2 > y1), facecolor='yellow', alpha=0.5)
ax.fill_between(x, y1, y2, where=(y2 <= y1), facecolor='red', alpha=0.5)
ax.set_title('Fill Between')

plt.show()

What's New 98 4 Fill Between

Lots more
---------
Expand Down
117 changes: 101 additions & 16 deletions doc/users/prev_whats_new/whats_new_0.99.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,29 @@ working with paths and transformations: :doc:`/tutorials/advanced/path_tutorial`
mplot3d
--------


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

.. figure:: ../../gallery/pyplots/images/sphx_glr_whats_new_99_mplot3d_001.png
:target: ../../gallery/pyplots/whats_new_99_mplot3d.html
:align: center
:scale: 50
.. plot::

from matplotlib import cm
from mpl_toolkits.mplot3d import Axes3D

X = np.arange(-5, 5, 0.25)
Y = np.arange(-5, 5, 0.25)
X, Y = np.meshgrid(X, Y)
R = np.sqrt(X**2 + Y**2)
Z = np.sin(R)

fig = plt.figure()
ax = Axes3D(fig, auto_add_to_figure=False)
fig.add_axes(ax)
ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=cm.viridis)

What's New 99 Mplot3d
plt.show()

.. _whats-new-axes-grid:

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

.. figure:: ../../gallery/pyplots/images/sphx_glr_whats_new_99_axes_grid_001.png
:target: ../../gallery/pyplots/whats_new_99_axes_grid.html
:align: center
:scale: 50
.. plot::

from mpl_toolkits.axes_grid1.axes_rgb import RGBAxes


def get_demo_image():
# prepare image
delta = 0.5

extent = (-3, 4, -4, 3)
x = np.arange(-3.0, 4.001, delta)
y = np.arange(-4.0, 3.001, delta)
X, Y = np.meshgrid(x, y)
Z1 = np.exp(-X**2 - Y**2)
Z2 = np.exp(-(X - 1)**2 - (Y - 1)**2)
Z = (Z1 - Z2) * 2

return Z, extent


def get_rgb():
Z, extent = get_demo_image()

Z[Z < 0] = 0.
Z = Z / Z.max()

R = Z[:13, :13]
G = Z[2:, 2:]
B = Z[:13, 2:]

return R, G, B

What's New 99 Axes Grid

fig = plt.figure()
ax = RGBAxes(fig, [0.1, 0.1, 0.8, 0.8])

r, g, b = get_rgb()
ax.imshow_rgb(r, g, b, origin="lower")

ax.RGB.set_xlim(0., 9.5)
ax.RGB.set_ylim(0.9, 10.6)

plt.show()

.. _whats-new-spine:

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

.. figure:: ../../gallery/pyplots/images/sphx_glr_whats_new_99_spines_001.png
:target: ../../gallery/pyplots/whats_new_99_spines.html
:align: center
:scale: 50
.. plot::

def adjust_spines(ax, spines):
for loc, spine in ax.spines.items():
if loc in spines:
spine.set_position(('outward', 10)) # outward by 10 points
else:
spine.set_color('none') # don't draw spine

# turn off ticks where there is no spine
if 'left' in spines:
ax.yaxis.set_ticks_position('left')
else:
# no yaxis ticks
ax.yaxis.set_ticks([])

if 'bottom' in spines:
ax.xaxis.set_ticks_position('bottom')
else:
# no xaxis ticks
ax.xaxis.set_ticks([])

fig = plt.figure()

x = np.linspace(0, 2*np.pi, 100)
y = 2*np.sin(x)

ax = fig.add_subplot(2, 2, 1)
ax.plot(x, y)
adjust_spines(ax, ['left'])

ax = fig.add_subplot(2, 2, 2)
ax.plot(x, y)
adjust_spines(ax, [])

ax = fig.add_subplot(2, 2, 3)
ax.plot(x, y)
adjust_spines(ax, ['left', 'bottom'])

ax = fig.add_subplot(2, 2, 4)
ax.plot(x, y)
adjust_spines(ax, ['bottom'])

What's New 99 Spines
plt.show()
Loading