From 1792a7a0b93ac358eafc20664cacd150ae702453 Mon Sep 17 00:00:00 2001 From: David Stansby Date: Wed, 8 Feb 2023 09:45:50 +0000 Subject: [PATCH 1/2] Add isort config --- .pre-commit-config.yaml | 7 +++++++ pyproject.toml | 9 +++++++++ 2 files changed, 16 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b29e1c1a7609..70db59c0e9fc 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -41,3 +41,10 @@ repos: "--skip", "doc/users/project/credits.rst" ] + + - repo: https://github.com/pycqa/isort + rev: 5.12.0 + hooks: + - id: isort + name: isort (python) + files: ^tutorials/|^examples/ diff --git a/pyproject.toml b/pyproject.toml index 907b05a39ba4..8c51b1556a3b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,3 +6,12 @@ requires = [ "pybind11>=2.6", "setuptools_scm>=7", ] + + +[tool.isort] +known_mpltoolkits = "mpl_toolkits" +known_pydata = "numpy, matplotlib.pyplot" +known_firstparty = "matplotlib" +sections = "FUTURE,STDLIB,THIRDPARTY,PYDATA,FIRSTPARTY,MPLTOOLKITS,LOCALFOLDER" +no_lines_before = "MPLTOOLKITS" +force_sort_within_sections = true From 18b9eb81e91e2dd6007e63141ac7573c70522a32 Mon Sep 17 00:00:00 2001 From: David Stansby Date: Wed, 8 Feb 2023 09:46:17 +0000 Subject: [PATCH 2/2] Run isort on examples and tutorials --- examples/animation/animate_decay.py | 3 ++- examples/animation/animated_histogram.py | 2 +- examples/animation/bayes_update.py | 3 ++- examples/animation/double_pendulum.py | 8 +++++--- examples/animation/dynamic_image.py | 3 ++- examples/animation/frame_grabbing_sgskip.py | 3 +++ examples/animation/multiple_axes.py | 3 ++- examples/animation/pause_resume.py | 3 ++- examples/animation/rain.py | 3 ++- examples/animation/random_walk.py | 3 ++- examples/animation/simple_anim.py | 3 ++- examples/animation/simple_scatter.py | 3 ++- examples/animation/strip_chart.py | 5 +++-- examples/animation/unchained.py | 3 ++- .../demo_anchored_direction_arrows.py | 4 ++-- examples/axes_grid1/demo_axes_divider.py | 5 +++-- examples/axes_grid1/demo_axes_grid.py | 4 ++-- examples/axes_grid1/demo_axes_grid2.py | 3 ++- examples/axes_grid1/demo_axes_hbox_divider.py | 4 ++-- examples/axes_grid1/demo_axes_rgb.py | 5 +++-- .../axes_grid1/demo_colorbar_of_inset_axes.py | 4 ++-- .../demo_colorbar_with_axes_divider.py | 1 + .../demo_colorbar_with_inset_locator.py | 1 + examples/axes_grid1/demo_edge_colorbar.py | 3 ++- examples/axes_grid1/demo_imagegrid_aspect.py | 1 + examples/axes_grid1/inset_locator_demo.py | 3 ++- examples/axes_grid1/inset_locator_demo2.py | 8 ++++---- .../make_room_for_ylabel_using_axesgrid.py | 1 - examples/axes_grid1/parasite_simple.py | 1 + examples/axes_grid1/parasite_simple2.py | 3 ++- .../axes_grid1/scatter_hist_locatable_axes.py | 3 ++- examples/axes_grid1/simple_anchored_artists.py | 2 +- examples/axes_grid1/simple_axes_divider1.py | 3 ++- examples/axes_grid1/simple_axes_divider3.py | 4 ++-- examples/axes_grid1/simple_axesgrid.py | 3 ++- examples/axes_grid1/simple_axesgrid2.py | 4 ++-- examples/axes_grid1/simple_axisline4.py | 3 ++- examples/axes_grid1/simple_colorbar.py | 3 ++- examples/axisartist/axis_direction.py | 1 + examples/axisartist/demo_axis_direction.py | 9 ++++----- examples/axisartist/demo_axisline_style.py | 2 +- examples/axisartist/demo_curvelinear_grid.py | 9 ++++----- examples/axisartist/demo_curvelinear_grid2.py | 10 +++++----- examples/axisartist/demo_floating_axes.py | 13 +++++++------ examples/axisartist/demo_floating_axis.py | 8 ++++---- examples/axisartist/demo_parasite_axes.py | 3 ++- examples/axisartist/demo_parasite_axes2.py | 5 +++-- examples/axisartist/demo_ticklabel_alignment.py | 1 + examples/axisartist/demo_ticklabel_direction.py | 1 + examples/axisartist/simple_axis_direction01.py | 1 + examples/axisartist/simple_axis_direction03.py | 1 + examples/axisartist/simple_axis_pad.py | 9 ++++----- examples/axisartist/simple_axisartist1.py | 2 +- examples/axisartist/simple_axisline.py | 2 +- examples/axisartist/simple_axisline3.py | 1 + examples/color/color_by_yvalue.py | 2 +- examples/color/color_cycle_default.py | 3 +-- examples/color/colorbar_basics.py | 2 +- examples/color/colormap_reference.py | 2 +- examples/color/custom_cmap.py | 3 ++- examples/color/named_colors.py | 3 ++- examples/event_handling/coords_demo.py | 3 ++- examples/event_handling/data_browser.py | 1 + .../ginput_manual_clabel_sgskip.py | 2 +- examples/event_handling/image_slices_viewer.py | 2 +- examples/event_handling/keypress_demo.py | 3 ++- examples/event_handling/lasso_demo.py | 8 +++++--- examples/event_handling/legend_picking.py | 3 +-- examples/event_handling/looking_glass.py | 3 ++- examples/event_handling/path_editor.py | 6 +++--- examples/event_handling/pick_event_demo.py | 8 ++++---- examples/event_handling/pick_event_demo2.py | 3 +-- examples/event_handling/poly_editor.py | 4 +++- examples/event_handling/pong_sgskip.py | 5 +++-- examples/event_handling/resample.py | 2 +- examples/event_handling/timers.py | 3 ++- examples/event_handling/trifinder_event_demo.py | 5 +++-- examples/event_handling/viewlims.py | 3 ++- examples/event_handling/zoom_window.py | 1 - .../images_contours_and_fields/affine_image.py | 3 ++- .../images_contours_and_fields/barcode_demo.py | 1 - .../colormap_normalizations.py | 3 ++- .../colormap_normalizations_symlognorm.py | 3 ++- .../images_contours_and_fields/contour_demo.py | 4 ++-- .../images_contours_and_fields/contour_image.py | 1 + .../contour_label_demo.py | 3 ++- .../images_contours_and_fields/contourf_demo.py | 2 +- .../images_contours_and_fields/contourf_log.py | 3 ++- .../contours_in_optimization_demo.py | 3 ++- .../demo_bboximage.py | 3 +-- .../images_contours_and_fields/figimage_demo.py | 3 +-- .../image_annotated_heatmap.py | 4 +++- .../image_antialiasing.py | 2 +- .../image_clip_path.py | 4 ++-- .../images_contours_and_fields/image_demo.py | 8 ++++---- .../images_contours_and_fields/image_masked.py | 3 ++- .../image_nonuniform.py | 5 +++-- .../image_transparency_blend.py | 3 ++- .../images_contours_and_fields/image_zcoord.py | 2 +- .../irregulardatagrid.py | 3 ++- .../images_contours_and_fields/multi_image.py | 3 ++- .../images_contours_and_fields/pcolor_demo.py | 2 +- .../pcolormesh_levels.py | 3 ++- .../plot_streamplot.py | 3 +-- .../images_contours_and_fields/quadmesh_demo.py | 3 ++- .../shading_example.py | 3 ++- .../images_contours_and_fields/spy_demos.py | 1 - .../tricontour_demo.py | 3 ++- .../tricontour_smooth_delaunay.py | 3 ++- .../tricontour_smooth_user.py | 3 ++- .../trigradient_demo.py | 5 +++-- .../triinterp_demo.py | 3 ++- .../tripcolor_demo.py | 3 ++- .../images_contours_and_fields/triplot_demo.py | 3 ++- .../watermark_image.py | 4 ++-- examples/lines_bars_and_markers/capstyle.py | 1 + examples/lines_bars_and_markers/cohere.py | 2 +- examples/lines_bars_and_markers/csd_demo.py | 3 +-- .../lines_bars_and_markers/curve_error_band.py | 4 ++-- .../errorbar_limits_simple.py | 3 +-- .../errorbar_subsample.py | 2 +- .../eventcollection_demo.py | 3 ++- .../lines_bars_and_markers/eventplot_demo.py | 2 ++ examples/lines_bars_and_markers/fill.py | 2 +- .../fill_between_alpha.py | 2 +- .../fill_betweenx_demo.py | 1 - examples/lines_bars_and_markers/filled_step.py | 8 +++++--- examples/lines_bars_and_markers/hat_graph.py | 2 +- .../horizontal_barchart_distribution.py | 3 +-- examples/lines_bars_and_markers/joinstyle.py | 1 + .../line_demo_dash_control.py | 2 +- .../lines_with_ticks_demo.py | 3 ++- examples/lines_bars_and_markers/linestyles.py | 2 +- .../lines_bars_and_markers/marker_reference.py | 9 +++++---- .../lines_bars_and_markers/markevery_demo.py | 2 +- examples/lines_bars_and_markers/masked_demo.py | 1 - .../lines_bars_and_markers/multicolored_line.py | 5 +++-- .../multivariate_marker_plot.py | 7 ++++--- examples/lines_bars_and_markers/psd_demo.py | 1 + .../lines_bars_and_markers/scatter_demo2.py | 3 ++- examples/lines_bars_and_markers/scatter_hist.py | 2 +- .../lines_bars_and_markers/scatter_star_poly.py | 2 +- .../scatter_with_legend.py | 2 +- examples/lines_bars_and_markers/span_regions.py | 3 +-- .../lines_bars_and_markers/spectrum_demo.py | 1 - .../lines_bars_and_markers/stackplot_demo.py | 2 +- examples/lines_bars_and_markers/stairs_demo.py | 3 ++- examples/lines_bars_and_markers/step_demo.py | 2 +- examples/lines_bars_and_markers/timeline.py | 6 ++++-- .../lines_bars_and_markers/vline_hline_demo.py | 1 - .../lines_bars_and_markers/xcorr_acorr_demo.py | 1 - examples/misc/anchored_artists.py | 4 ++-- examples/misc/bbox_intersect.py | 5 +++-- examples/misc/contour_manual.py | 4 ++-- examples/misc/custom_projection.py | 10 ++++++---- examples/misc/demo_agg_filter.py | 9 +++++---- examples/misc/demo_ribbon_box.py | 7 ++++--- examples/misc/fig_x.py | 2 +- examples/misc/findobj_demo.py | 3 ++- examples/misc/font_indexing.py | 5 ++--- examples/misc/ftface_props.py | 1 - examples/misc/histogram_path.py | 3 ++- examples/misc/hyperlinks_sgskip.py | 3 ++- examples/misc/image_thumbnail_sgskip.py | 2 +- examples/misc/keyword_plotting.py | 3 ++- examples/misc/logos2.py | 5 +++-- examples/misc/multipage_pdf.py | 4 +++- examples/misc/packed_bubbles.py | 2 +- examples/misc/patheffect_demo.py | 3 ++- examples/misc/print_stdout_sgskip.py | 2 ++ examples/misc/rasterization_demo.py | 2 +- examples/misc/set_and_get.py | 1 - examples/misc/svg_filter_line.py | 1 + examples/misc/svg_filter_pie.py | 1 + examples/misc/table_demo.py | 3 +-- examples/misc/tickedstroke_demo.py | 5 +++-- examples/misc/transoffset.py | 2 +- examples/mplot3d/2dcollections3d.py | 2 +- examples/mplot3d/3d_bars.py | 3 +-- examples/mplot3d/contour3d.py | 3 ++- examples/mplot3d/contour3d_2.py | 3 ++- examples/mplot3d/contour3d_3.py | 3 ++- examples/mplot3d/contourf3d.py | 3 ++- examples/mplot3d/contourf3d_2.py | 3 ++- examples/mplot3d/custom_shaded_3d_surface.py | 6 +++--- examples/mplot3d/lines3d.py | 3 +-- examples/mplot3d/lorenz_attractor.py | 2 +- examples/mplot3d/offset.py | 1 - examples/mplot3d/pathpatch3d.py | 3 ++- examples/mplot3d/polys3d.py | 6 ++++-- examples/mplot3d/projections.py | 2 +- examples/mplot3d/rotate_axes3d_sgskip.py | 3 ++- examples/mplot3d/subplot3d.py | 3 +-- examples/mplot3d/surface3d.py | 3 ++- examples/mplot3d/surface3d_2.py | 1 - examples/mplot3d/surface3d_3.py | 2 +- examples/mplot3d/surface3d_radial.py | 1 - examples/mplot3d/text3d.py | 1 - examples/mplot3d/tricontour3d.py | 3 ++- examples/mplot3d/tricontourf3d.py | 3 ++- examples/mplot3d/trisurf3d.py | 1 - examples/mplot3d/trisurf3d_2.py | 4 ++-- examples/mplot3d/voxels.py | 1 - examples/mplot3d/voxels_torus.py | 3 ++- examples/mplot3d/wire3d.py | 2 +- examples/mplot3d/wire3d_animation_sgskip.py | 4 ++-- examples/mplot3d/wire3d_zero_stride.py | 2 +- examples/pie_and_polar_charts/bar_of_pie.py | 3 ++- .../pie_and_donut_labels.py | 2 +- examples/pie_and_polar_charts/pie_features.py | 1 + examples/pie_and_polar_charts/polar_bar.py | 3 +-- examples/pie_and_polar_charts/polar_demo.py | 3 +-- .../pie_and_polar_charts/polar_error_caps.py | 2 +- examples/pie_and_polar_charts/polar_scatter.py | 3 +-- examples/pyplots/axline.py | 2 +- examples/pyplots/pyplot_text.py | 2 +- examples/pyplots/pyplot_three.py | 2 +- examples/pyplots/pyplot_two_subplots.py | 2 +- examples/scales/asinh_demo.py | 2 +- examples/scales/custom_scale.py | 1 + examples/scales/log_demo.py | 2 +- examples/scales/logit_demo.py | 2 +- examples/scales/power_norm.py | 2 +- examples/scales/scales.py | 5 +++-- examples/shapes_and_collections/arrow_guide.py | 4 +++- .../shapes_and_collections/artist_reference.py | 3 ++- examples/shapes_and_collections/collections.py | 3 ++- .../shapes_and_collections/compound_path.py | 5 +++-- examples/shapes_and_collections/dolphin.py | 5 +++-- examples/shapes_and_collections/donut.py | 5 +++-- .../ellipse_collection.py | 1 + examples/shapes_and_collections/ellipse_demo.py | 2 +- .../shapes_and_collections/fancybox_demo.py | 3 ++- examples/shapes_and_collections/hatch_demo.py | 3 ++- .../hatch_style_reference.py | 1 + .../shapes_and_collections/line_collection.py | 3 +-- .../shapes_and_collections/patch_collection.py | 5 +++-- examples/shapes_and_collections/path_patch.py | 5 +++-- examples/shapes_and_collections/quad_bezier.py | 5 +++-- examples/shapes_and_collections/scatter.py | 2 +- examples/showcase/anatomy.py | 3 ++- examples/showcase/firefox.py | 6 ++++-- examples/showcase/integral.py | 3 ++- examples/showcase/mandelbrot.py | 4 +++- examples/showcase/stock_prices.py | 5 +++-- .../specialty_plots/advanced_hillshading.py | 3 ++- examples/specialty_plots/hinton_demo.py | 2 +- .../specialty_plots/leftventricle_bullseye.py | 3 ++- examples/specialty_plots/mri_demo.py | 2 +- examples/specialty_plots/mri_with_eeg.py | 4 ++-- examples/specialty_plots/radar_chart.py | 4 ++-- examples/specialty_plots/sankey_basics.py | 1 - examples/specialty_plots/sankey_links.py | 1 + examples/specialty_plots/skewt.py | 10 ++++++---- .../specialty_plots/topographic_hillshading.py | 4 ++-- examples/spines/centered_spines_with_arrows.py | 1 - examples/spines/spine_placement_demo.py | 3 +-- examples/spines/spines.py | 3 +-- examples/spines/spines_dropped.py | 2 +- examples/statistics/barchart_demo.py | 4 ++-- examples/statistics/boxplot.py | 2 +- examples/statistics/boxplot_demo.py | 2 +- examples/statistics/bxp.py | 3 ++- examples/statistics/confidence_ellipse.py | 4 ++-- examples/statistics/errorbar.py | 2 +- examples/statistics/errorbar_features.py | 2 +- examples/statistics/errorbar_limits.py | 2 +- examples/statistics/errorbars_and_boxes.py | 3 ++- examples/statistics/hexbin_demo.py | 2 +- examples/statistics/hist.py | 1 + examples/statistics/histogram_cumulative.py | 2 +- examples/statistics/histogram_features.py | 2 +- examples/statistics/histogram_histtypes.py | 2 +- examples/statistics/histogram_multihist.py | 2 +- .../multiple_histograms_side_by_side.py | 2 +- examples/statistics/time_series_histogram.py | 3 ++- examples/statistics/violinplot.py | 2 +- examples/style_sheets/bmh.py | 3 +-- examples/style_sheets/dark_background.py | 3 +-- examples/style_sheets/fivethirtyeight.py | 1 - examples/style_sheets/ggplot.py | 2 +- examples/style_sheets/grayscale.py | 2 +- examples/style_sheets/plot_solarizedlight2.py | 1 - examples/style_sheets/style_sheets_reference.py | 3 ++- .../align_labels_demo.py | 1 + .../auto_subplots_adjust.py | 1 + .../axes_box_aspect.py | 2 +- .../subplots_axes_and_figures/axes_margins.py | 3 ++- .../axes_zoom_effect.py | 9 +++++---- .../subplots_axes_and_figures/axhspan_demo.py | 2 +- .../subplots_axes_and_figures/broken_axis.py | 2 +- .../colorbar_placement.py | 1 - .../custom_figure_class.py | 3 ++- .../demo_tight_layout.py | 2 +- .../figure_size_units.py | 1 + .../subplots_axes_and_figures/figure_title.py | 3 +-- .../gridspec_multicolumn.py | 1 + .../gridspec_nested.py | 1 + .../subplots_axes_and_figures/secondary_axis.py | 4 +++- .../share_axis_lims_views.py | 2 +- examples/subplots_axes_and_figures/subplot.py | 2 +- .../subplots_axes_and_figures/two_scales.py | 2 +- .../zoom_inset_axes.py | 3 ++- .../align_ylabels.py | 2 +- .../angle_annotation.py | 5 +++-- .../angles_on_bracket_arrows.py | 1 + .../annotate_transform.py | 2 +- .../annotation_basic.py | 2 +- .../annotation_demo.py | 4 ++-- .../annotation_polar.py | 2 +- .../custom_legends.py | 8 +++++--- examples/text_labels_and_annotations/date.py | 3 ++- .../demo_annotation_box.py | 7 +++---- .../demo_text_path.py | 7 ++++--- .../fancyarrow_demo.py | 5 +++-- .../figlegend_demo.py | 2 +- .../text_labels_and_annotations/font_file.py | 3 ++- .../text_labels_and_annotations/font_table.py | 3 ++- .../text_labels_and_annotations/fonts_demo.py | 3 ++- .../label_subplots.py | 1 + examples/text_labels_and_annotations/legend.py | 2 +- .../text_labels_and_annotations/legend_demo.py | 3 ++- .../line_with_text.py | 5 +++-- .../mathtext_asarray.py | 3 ++- .../mathtext_examples.py | 1 - .../mathtext_fontfamily_example.py | 1 - .../placing_text_boxes.py | 2 +- .../text_labels_and_annotations/rainbow_text.py | 1 + .../stix_fonts_demo.py | 1 - .../text_labels_and_annotations/tex_demo.py | 2 +- .../text_fontdict.py | 3 +-- .../usetex_baseline_test.py | 1 - .../watermark_text.py | 2 +- examples/ticks/auto_ticks.py | 1 + examples/ticks/centered_ticklabels.py | 3 ++- examples/ticks/colorbar_tick_labelling_demo.py | 2 +- examples/ticks/date_concise_formatter.py | 5 ++++- examples/ticks/date_demo_convert.py | 4 +++- examples/ticks/date_demo_rrule.py | 8 +++++--- examples/ticks/date_formatters_locators.py | 15 ++++++++------- examples/ticks/date_index_formatter.py | 6 +++--- examples/ticks/date_precision_and_epochs.py | 3 ++- examples/ticks/dollar_ticks.py | 2 +- examples/ticks/major_minor_demo.py | 2 +- examples/ticks/tick-formatters.py | 1 + examples/ticks/tick-locators.py | 3 ++- examples/ticks/tick_labels_from_values.py | 2 +- examples/ticks/ticklabels_rotation.py | 1 - examples/units/annotate_with_units.py | 3 ++- examples/units/artist_tests.py | 12 +++++++----- examples/units/bar_demo2.py | 3 ++- examples/units/bar_unit_demo.py | 4 ++-- examples/units/basic_units.py | 5 +++-- examples/units/ellipse_with_units.py | 5 +++-- examples/units/evans_test.py | 4 ++-- examples/units/radian_demo.py | 4 ++-- examples/units/units_sample.py | 1 + examples/units/units_scatter.py | 5 +++-- examples/user_interfaces/canvasagg.py | 7 ++++--- .../embedding_in_gtk3_panzoom_sgskip.py | 12 +++++++----- .../user_interfaces/embedding_in_gtk3_sgskip.py | 8 +++++--- .../embedding_in_gtk4_panzoom_sgskip.py | 12 +++++++----- .../user_interfaces/embedding_in_gtk4_sgskip.py | 8 +++++--- .../user_interfaces/embedding_in_qt_sgskip.py | 5 +++-- .../user_interfaces/embedding_in_tk_sgskip.py | 9 ++++----- .../user_interfaces/embedding_in_wx2_sgskip.py | 12 ++++++------ .../user_interfaces/embedding_in_wx3_sgskip.py | 17 +++++++++-------- .../user_interfaces/embedding_in_wx4_sgskip.py | 11 +++++------ .../user_interfaces/embedding_in_wx5_sgskip.py | 6 +++--- .../user_interfaces/embedding_webagg_sgskip.py | 5 ++--- .../user_interfaces/fourier_demo_wx_sgskip.py | 3 ++- .../user_interfaces/gtk3_spreadsheet_sgskip.py | 7 ++++--- .../user_interfaces/gtk4_spreadsheet_sgskip.py | 5 +++-- examples/user_interfaces/mathtext_wx_sgskip.py | 8 +++++--- .../user_interfaces/mpl_with_glade3_sgskip.py | 9 ++++++--- examples/user_interfaces/mplcvd.py | 3 ++- .../user_interfaces/pylab_with_gtk3_sgskip.py | 5 +++-- .../user_interfaces/pylab_with_gtk4_sgskip.py | 5 +++-- .../user_interfaces/svg_histogram_sgskip.py | 6 +++--- examples/user_interfaces/svg_tooltip_sgskip.py | 5 +++-- examples/user_interfaces/toolmanager_sgskip.py | 2 +- .../web_application_server_sgskip.py | 1 + .../user_interfaces/wxcursor_demo_sgskip.py | 9 +++++---- examples/userdemo/annotate_explain.py | 2 +- examples/userdemo/annotate_simple_coord02.py | 1 - examples/userdemo/annotate_text_arrow.py | 3 +-- examples/userdemo/connect_simple01.py | 3 ++- examples/userdemo/custom_boxstyle01.py | 4 ++-- examples/userdemo/demo_gridspec03.py | 1 + examples/userdemo/pgf_fonts.py | 1 + examples/userdemo/pgf_preamble_sgskip.py | 2 ++ examples/userdemo/pgf_texsystem.py | 1 + examples/userdemo/simple_annotate01.py | 2 +- examples/userdemo/simple_legend01.py | 1 - examples/widgets/annotated_cursor.py | 4 ++-- examples/widgets/buttons.py | 3 ++- examples/widgets/check_buttons.py | 3 ++- examples/widgets/cursor.py | 4 ++-- examples/widgets/lasso_selector_demo_sgskip.py | 2 +- examples/widgets/menu.py | 3 ++- examples/widgets/mouse_cursor.py | 2 +- examples/widgets/multicursor.py | 3 ++- examples/widgets/polygon_selector_demo.py | 2 +- examples/widgets/polygon_selector_simple.py | 1 + examples/widgets/radio_buttons.py | 3 ++- examples/widgets/range_slider.py | 3 ++- examples/widgets/rectangle_selector.py | 5 +++-- examples/widgets/slider_demo.py | 5 +++-- examples/widgets/slider_snap_demo.py | 5 +++-- examples/widgets/span_selector.py | 3 ++- examples/widgets/textbox.py | 4 ++-- tutorials/advanced/path_tutorial.py | 4 +++- tutorials/advanced/patheffects_guide.py | 1 + tutorials/advanced/transforms_tutorial.py | 3 ++- tutorials/colors/colorbar_only.py | 1 + tutorials/colors/colormap-manipulation.py | 5 +++-- tutorials/colors/colormapnorms.py | 7 ++++--- tutorials/colors/colormaps.py | 7 ++++--- tutorials/colors/colors.py | 6 ++++-- tutorials/intermediate/artists.py | 2 +- tutorials/intermediate/autoscale.py | 3 ++- tutorials/intermediate/color_cycle.py | 3 ++- .../intermediate/constrainedlayout_guide.py | 3 ++- tutorials/intermediate/imshow_extent.py | 3 ++- tutorials/intermediate/legend_guide.py | 3 ++- tutorials/introductory/animation_tutorial.py | 3 ++- tutorials/introductory/customizing.py | 7 +++++-- tutorials/introductory/images.py | 3 ++- tutorials/introductory/lifecycle.py | 3 +-- tutorials/introductory/pyplot.py | 1 + tutorials/introductory/quick_start.py | 5 +++-- tutorials/text/annotations.py | 2 +- tutorials/text/text_intro.py | 3 ++- tutorials/text/text_props.py | 1 + 434 files changed, 830 insertions(+), 620 deletions(-) diff --git a/examples/animation/animate_decay.py b/examples/animation/animate_decay.py index a96dd2a5952a..8fbc570bf437 100644 --- a/examples/animation/animate_decay.py +++ b/examples/animation/animate_decay.py @@ -13,8 +13,9 @@ import itertools -import numpy as np import matplotlib.pyplot as plt +import numpy as np + import matplotlib.animation as animation diff --git a/examples/animation/animated_histogram.py b/examples/animation/animated_histogram.py index 8b918895de71..a6345cc71579 100644 --- a/examples/animation/animated_histogram.py +++ b/examples/animation/animated_histogram.py @@ -7,9 +7,9 @@ histogram. """ +import matplotlib.pyplot as plt import numpy as np -import matplotlib.pyplot as plt import matplotlib.animation as animation # Fixing random state for reproducibility diff --git a/examples/animation/bayes_update.py b/examples/animation/bayes_update.py index 3874cef5aa9b..49763ba7ec4b 100644 --- a/examples/animation/bayes_update.py +++ b/examples/animation/bayes_update.py @@ -13,8 +13,9 @@ import math -import numpy as np import matplotlib.pyplot as plt +import numpy as np + from matplotlib.animation import FuncAnimation diff --git a/examples/animation/double_pendulum.py b/examples/animation/double_pendulum.py index 6009245d12df..4ca1877126b5 100644 --- a/examples/animation/double_pendulum.py +++ b/examples/animation/double_pendulum.py @@ -11,11 +11,13 @@ Output generate via `matplotlib.animation.Animation.to_jshtml`. """ -from numpy import sin, cos -import numpy as np +from collections import deque + import matplotlib.pyplot as plt +import numpy as np +from numpy import cos, sin + import matplotlib.animation as animation -from collections import deque G = 9.8 # acceleration due to gravity, in m/s^2 L1 = 1.0 # length of pendulum 1 in m diff --git a/examples/animation/dynamic_image.py b/examples/animation/dynamic_image.py index 41bc7e54e908..3b17450fad42 100644 --- a/examples/animation/dynamic_image.py +++ b/examples/animation/dynamic_image.py @@ -6,8 +6,9 @@ Output generate via `matplotlib.animation.Animation.to_jshtml`. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np + import matplotlib.animation as animation fig, ax = plt.subplots() diff --git a/examples/animation/frame_grabbing_sgskip.py b/examples/animation/frame_grabbing_sgskip.py index 1cdd47f0d70a..f40d7d190f12 100644 --- a/examples/animation/frame_grabbing_sgskip.py +++ b/examples/animation/frame_grabbing_sgskip.py @@ -11,9 +11,12 @@ """ import numpy as np + import matplotlib + matplotlib.use("Agg") import matplotlib.pyplot as plt + from matplotlib.animation import FFMpegWriter # Fixing random state for reproducibility diff --git a/examples/animation/multiple_axes.py b/examples/animation/multiple_axes.py index 349c979e267b..2b649b8b6cb9 100644 --- a/examples/animation/multiple_axes.py +++ b/examples/animation/multiple_axes.py @@ -11,8 +11,9 @@ Output generate via `matplotlib.animation.Animation.to_jshtml`. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np + import matplotlib.animation as animation from matplotlib.patches import ConnectionPatch diff --git a/examples/animation/pause_resume.py b/examples/animation/pause_resume.py index 4f9dc3c39d99..b19a4e35f0c9 100644 --- a/examples/animation/pause_resume.py +++ b/examples/animation/pause_resume.py @@ -20,9 +20,10 @@ """ import matplotlib.pyplot as plt -import matplotlib.animation as animation import numpy as np +import matplotlib.animation as animation + class PauseAnimation: def __init__(self): diff --git a/examples/animation/rain.py b/examples/animation/rain.py index affa1d33867c..760ca01cea81 100644 --- a/examples/animation/rain.py +++ b/examples/animation/rain.py @@ -11,8 +11,9 @@ Output generate via `matplotlib.animation.Animation.to_jshtml`. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np + from matplotlib.animation import FuncAnimation # Fixing random state for reproducibility diff --git a/examples/animation/random_walk.py b/examples/animation/random_walk.py index e7e539f8884e..05351b22ac3b 100644 --- a/examples/animation/random_walk.py +++ b/examples/animation/random_walk.py @@ -6,8 +6,9 @@ Output generate via `matplotlib.animation.Animation.to_jshtml`. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np + import matplotlib.animation as animation # Fixing random state for reproducibility diff --git a/examples/animation/simple_anim.py b/examples/animation/simple_anim.py index 4fe404521b7c..39b7eb46efd7 100644 --- a/examples/animation/simple_anim.py +++ b/examples/animation/simple_anim.py @@ -6,8 +6,9 @@ Output generate via `matplotlib.animation.Animation.to_jshtml`. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np + import matplotlib.animation as animation fig, ax = plt.subplots() diff --git a/examples/animation/simple_scatter.py b/examples/animation/simple_scatter.py index c0bfa8bfa535..3979c1294755 100644 --- a/examples/animation/simple_scatter.py +++ b/examples/animation/simple_scatter.py @@ -5,8 +5,9 @@ Output generate via `matplotlib.animation.Animation.to_jshtml`. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np + import matplotlib.animation as animation fig, ax = plt.subplots() diff --git a/examples/animation/strip_chart.py b/examples/animation/strip_chart.py index 77ea65b35fc2..5c5c0da0e291 100644 --- a/examples/animation/strip_chart.py +++ b/examples/animation/strip_chart.py @@ -8,10 +8,11 @@ Output generate via `matplotlib.animation.Animation.to_jshtml`. """ -import numpy as np -from matplotlib.lines import Line2D import matplotlib.pyplot as plt +import numpy as np + import matplotlib.animation as animation +from matplotlib.lines import Line2D class Scope: diff --git a/examples/animation/unchained.py b/examples/animation/unchained.py index 8a241ebfd61c..82015e107b0b 100644 --- a/examples/animation/unchained.py +++ b/examples/animation/unchained.py @@ -11,8 +11,9 @@ Output generate via `matplotlib.animation.Animation.to_jshtml`. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np + import matplotlib.animation as animation # Fixing random state for reproducibility diff --git a/examples/axes_grid1/demo_anchored_direction_arrows.py b/examples/axes_grid1/demo_anchored_direction_arrows.py index 24d3ddfcc4ad..f7d8fbc83868 100644 --- a/examples/axes_grid1/demo_anchored_direction_arrows.py +++ b/examples/axes_grid1/demo_anchored_direction_arrows.py @@ -6,9 +6,9 @@ """ import matplotlib.pyplot as plt import numpy as np -from mpl_toolkits.axes_grid1.anchored_artists import AnchoredDirectionArrows -import matplotlib.font_manager as fm +import matplotlib.font_manager as fm +from mpl_toolkits.axes_grid1.anchored_artists import AnchoredDirectionArrows # Fixing random state for reproducibility np.random.seed(19680801) diff --git a/examples/axes_grid1/demo_axes_divider.py b/examples/axes_grid1/demo_axes_divider.py index 242c33a935a2..b16daeab9831 100644 --- a/examples/axes_grid1/demo_axes_divider.py +++ b/examples/axes_grid1/demo_axes_divider.py @@ -7,9 +7,10 @@ create a divider for them using existing axes instances. """ -from matplotlib import cbook import matplotlib.pyplot as plt +from matplotlib import cbook + def get_demo_image(): z = cbook.get_sample_data("axes_grid/bivariate_normal.npy", np_load=True) @@ -27,7 +28,7 @@ def demo_simple_image(ax): def demo_locatable_axes_hard(fig): - from mpl_toolkits.axes_grid1 import SubplotDivider, Size + from mpl_toolkits.axes_grid1 import Size, SubplotDivider from mpl_toolkits.axes_grid1.mpl_axes import Axes divider = SubplotDivider(fig, 2, 2, 2, aspect=True) diff --git a/examples/axes_grid1/demo_axes_grid.py b/examples/axes_grid1/demo_axes_grid.py index 27d0f3268b01..a10d8e98d5f1 100644 --- a/examples/axes_grid1/demo_axes_grid.py +++ b/examples/axes_grid1/demo_axes_grid.py @@ -6,10 +6,10 @@ Grid of 2x2 images with a single colorbar or with one colorbar per axes. """ -from matplotlib import cbook import matplotlib.pyplot as plt -from mpl_toolkits.axes_grid1 import ImageGrid +from matplotlib import cbook +from mpl_toolkits.axes_grid1 import ImageGrid Z = cbook.get_sample_data( # (15, 15) array "axes_grid/bivariate_normal.npy", np_load=True) diff --git a/examples/axes_grid1/demo_axes_grid2.py b/examples/axes_grid1/demo_axes_grid2.py index 488460921471..ec55a5548712 100644 --- a/examples/axes_grid1/demo_axes_grid2.py +++ b/examples/axes_grid1/demo_axes_grid2.py @@ -6,10 +6,11 @@ Grid of images with shared xaxis and yaxis. """ +import matplotlib.pyplot as plt import numpy as np + from matplotlib import cbook import matplotlib.colors -import matplotlib.pyplot as plt from mpl_toolkits.axes_grid1 import ImageGrid diff --git a/examples/axes_grid1/demo_axes_hbox_divider.py b/examples/axes_grid1/demo_axes_hbox_divider.py index 81e0d09f2d6a..65d6764a3374 100644 --- a/examples/axes_grid1/demo_axes_hbox_divider.py +++ b/examples/axes_grid1/demo_axes_hbox_divider.py @@ -10,12 +10,12 @@ """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np + from mpl_toolkits.axes_grid1.axes_divider import HBoxDivider, VBoxDivider import mpl_toolkits.axes_grid1.axes_size as Size - arr1 = np.arange(20).reshape((4, 5)) arr2 = np.arange(20).reshape((5, 4)) diff --git a/examples/axes_grid1/demo_axes_rgb.py b/examples/axes_grid1/demo_axes_rgb.py index fa6ffdb5df3e..54f961b3b903 100644 --- a/examples/axes_grid1/demo_axes_rgb.py +++ b/examples/axes_grid1/demo_axes_rgb.py @@ -8,10 +8,11 @@ channels. """ +import matplotlib.pyplot as plt import numpy as np + from matplotlib import cbook -import matplotlib.pyplot as plt -from mpl_toolkits.axes_grid1.axes_rgb import make_rgb_axes, RGBAxes +from mpl_toolkits.axes_grid1.axes_rgb import RGBAxes, make_rgb_axes def get_rgb(): diff --git a/examples/axes_grid1/demo_colorbar_of_inset_axes.py b/examples/axes_grid1/demo_colorbar_of_inset_axes.py index bb0023adac3f..7c0b3e74f210 100644 --- a/examples/axes_grid1/demo_colorbar_of_inset_axes.py +++ b/examples/axes_grid1/demo_colorbar_of_inset_axes.py @@ -4,10 +4,10 @@ =============================== """ -from matplotlib import cbook import matplotlib.pyplot as plt -from mpl_toolkits.axes_grid1.inset_locator import inset_axes, zoomed_inset_axes +from matplotlib import cbook +from mpl_toolkits.axes_grid1.inset_locator import inset_axes, zoomed_inset_axes fig, ax = plt.subplots(figsize=[5, 4]) ax.set(aspect=1, xlim=(-15, 15), ylim=(-20, 5)) diff --git a/examples/axes_grid1/demo_colorbar_with_axes_divider.py b/examples/axes_grid1/demo_colorbar_with_axes_divider.py index 920db5703b98..49b98a852f06 100644 --- a/examples/axes_grid1/demo_colorbar_with_axes_divider.py +++ b/examples/axes_grid1/demo_colorbar_with_axes_divider.py @@ -11,6 +11,7 @@ """ import matplotlib.pyplot as plt + from mpl_toolkits.axes_grid1.axes_divider import make_axes_locatable fig, (ax1, ax2) = plt.subplots(1, 2) diff --git a/examples/axes_grid1/demo_colorbar_with_inset_locator.py b/examples/axes_grid1/demo_colorbar_with_inset_locator.py index 87939800021d..0c8d48e23101 100644 --- a/examples/axes_grid1/demo_colorbar_with_inset_locator.py +++ b/examples/axes_grid1/demo_colorbar_with_inset_locator.py @@ -13,6 +13,7 @@ """ import matplotlib.pyplot as plt + from mpl_toolkits.axes_grid1.inset_locator import inset_axes fig, (ax1, ax2) = plt.subplots(1, 2, figsize=[6, 3]) diff --git a/examples/axes_grid1/demo_edge_colorbar.py b/examples/axes_grid1/demo_edge_colorbar.py index 17dfd952992c..31b4573844ce 100644 --- a/examples/axes_grid1/demo_edge_colorbar.py +++ b/examples/axes_grid1/demo_edge_colorbar.py @@ -7,8 +7,9 @@ of an image grid. """ -from matplotlib import cbook import matplotlib.pyplot as plt + +from matplotlib import cbook from mpl_toolkits.axes_grid1 import AxesGrid diff --git a/examples/axes_grid1/demo_imagegrid_aspect.py b/examples/axes_grid1/demo_imagegrid_aspect.py index 5c29b802f1a0..820a2e8e1d2d 100644 --- a/examples/axes_grid1/demo_imagegrid_aspect.py +++ b/examples/axes_grid1/demo_imagegrid_aspect.py @@ -5,6 +5,7 @@ """ import matplotlib.pyplot as plt + from mpl_toolkits.axes_grid1 import ImageGrid fig = plt.figure() diff --git a/examples/axes_grid1/inset_locator_demo.py b/examples/axes_grid1/inset_locator_demo.py index 8c0c68b8785d..b0af820a4253 100644 --- a/examples/axes_grid1/inset_locator_demo.py +++ b/examples/axes_grid1/inset_locator_demo.py @@ -14,8 +14,8 @@ # controlled via the *borderpad* parameter. import matplotlib.pyplot as plt -from mpl_toolkits.axes_grid1.inset_locator import inset_axes +from mpl_toolkits.axes_grid1.inset_locator import inset_axes fig, (ax, ax2) = plt.subplots(1, 2, figsize=[5.5, 2.8]) @@ -136,6 +136,7 @@ # Create an inset horizontally centered in figure coordinates and vertically # bound to line up with the axes. from matplotlib.transforms import blended_transform_factory # noqa + transform = blended_transform_factory(fig.transFigure, ax2.transAxes) axins4 = inset_axes(ax2, width="16%", height="34%", bbox_to_anchor=(0, 0, 1, 1), diff --git a/examples/axes_grid1/inset_locator_demo2.py b/examples/axes_grid1/inset_locator_demo2.py index 11d80702c094..a0a669a1962a 100644 --- a/examples/axes_grid1/inset_locator_demo2.py +++ b/examples/axes_grid1/inset_locator_demo2.py @@ -12,13 +12,13 @@ :doc:`/gallery/subplots_axes_and_figures/zoom_inset_axes`. """ -from matplotlib import cbook import matplotlib.pyplot as plt -from mpl_toolkits.axes_grid1.inset_locator import zoomed_inset_axes, mark_inset -from mpl_toolkits.axes_grid1.anchored_artists import AnchoredSizeBar - import numpy as np +from matplotlib import cbook +from mpl_toolkits.axes_grid1.anchored_artists import AnchoredSizeBar +from mpl_toolkits.axes_grid1.inset_locator import mark_inset, zoomed_inset_axes + def get_demo_image(): z = cbook.get_sample_data("axes_grid/bivariate_normal.npy", np_load=True) diff --git a/examples/axes_grid1/make_room_for_ylabel_using_axesgrid.py b/examples/axes_grid1/make_room_for_ylabel_using_axesgrid.py index f350af22ee00..f130ef4a6de2 100644 --- a/examples/axes_grid1/make_room_for_ylabel_using_axesgrid.py +++ b/examples/axes_grid1/make_room_for_ylabel_using_axesgrid.py @@ -9,7 +9,6 @@ from mpl_toolkits.axes_grid1 import make_axes_locatable from mpl_toolkits.axes_grid1.axes_divider import make_axes_area_auto_adjustable - fig = plt.figure() ax = fig.add_axes([0, 0, 1, 1]) diff --git a/examples/axes_grid1/parasite_simple.py b/examples/axes_grid1/parasite_simple.py index 36f36f9c997e..ad4922308a3f 100644 --- a/examples/axes_grid1/parasite_simple.py +++ b/examples/axes_grid1/parasite_simple.py @@ -5,6 +5,7 @@ """ import matplotlib.pyplot as plt + from mpl_toolkits.axes_grid1 import host_subplot host = host_subplot(111) diff --git a/examples/axes_grid1/parasite_simple2.py b/examples/axes_grid1/parasite_simple2.py index f508ddb3551c..3f587e08e9c4 100644 --- a/examples/axes_grid1/parasite_simple2.py +++ b/examples/axes_grid1/parasite_simple2.py @@ -4,8 +4,9 @@ ================ """ -import matplotlib.transforms as mtransforms import matplotlib.pyplot as plt + +import matplotlib.transforms as mtransforms from mpl_toolkits.axes_grid1.parasite_axes import HostAxes obs = [["01_S1", 3.88, 0.14, 1970, 63], diff --git a/examples/axes_grid1/scatter_hist_locatable_axes.py b/examples/axes_grid1/scatter_hist_locatable_axes.py index e560cd969895..8304334b90eb 100644 --- a/examples/axes_grid1/scatter_hist_locatable_axes.py +++ b/examples/axes_grid1/scatter_hist_locatable_axes.py @@ -15,8 +15,9 @@ :doc:`/gallery/lines_bars_and_markers/scatter_hist` example. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np + from mpl_toolkits.axes_grid1 import make_axes_locatable # Fixing random state for reproducibility diff --git a/examples/axes_grid1/simple_anchored_artists.py b/examples/axes_grid1/simple_anchored_artists.py index 212f9797a7f7..d802178ea166 100644 --- a/examples/axes_grid1/simple_anchored_artists.py +++ b/examples/axes_grid1/simple_anchored_artists.py @@ -37,8 +37,8 @@ def draw_circle(ax): """ Draw a circle in axis coordinates """ - from mpl_toolkits.axes_grid1.anchored_artists import AnchoredDrawingArea from matplotlib.patches import Circle + from mpl_toolkits.axes_grid1.anchored_artists import AnchoredDrawingArea ada = AnchoredDrawingArea(20, 20, 0, 0, loc='upper right', pad=0., frameon=False) p = Circle((10, 10), 10) diff --git a/examples/axes_grid1/simple_axes_divider1.py b/examples/axes_grid1/simple_axes_divider1.py index d86117760548..0a35ebc92e6e 100644 --- a/examples/axes_grid1/simple_axes_divider1.py +++ b/examples/axes_grid1/simple_axes_divider1.py @@ -6,9 +6,10 @@ See also :doc:`/tutorials/toolkits/axes_grid`. """ -from mpl_toolkits.axes_grid1 import Size, Divider import matplotlib.pyplot as plt +from mpl_toolkits.axes_grid1 import Divider, Size + def label_axes(ax, text): """Place a label at the center of an Axes, and remove the axis ticks.""" diff --git a/examples/axes_grid1/simple_axes_divider3.py b/examples/axes_grid1/simple_axes_divider3.py index 7f88936c2deb..e9573f3c5c2a 100644 --- a/examples/axes_grid1/simple_axes_divider3.py +++ b/examples/axes_grid1/simple_axes_divider3.py @@ -6,10 +6,10 @@ See also :doc:`/tutorials/toolkits/axes_grid`. """ -import mpl_toolkits.axes_grid1.axes_size as Size -from mpl_toolkits.axes_grid1 import Divider import matplotlib.pyplot as plt +from mpl_toolkits.axes_grid1 import Divider +import mpl_toolkits.axes_grid1.axes_size as Size fig = plt.figure(figsize=(5.5, 4)) diff --git a/examples/axes_grid1/simple_axesgrid.py b/examples/axes_grid1/simple_axesgrid.py index fdd94cd32244..ef13fdd74aee 100644 --- a/examples/axes_grid1/simple_axesgrid.py +++ b/examples/axes_grid1/simple_axesgrid.py @@ -7,9 +7,10 @@ """ import matplotlib.pyplot as plt -from mpl_toolkits.axes_grid1 import ImageGrid import numpy as np +from mpl_toolkits.axes_grid1 import ImageGrid + im1 = np.arange(100).reshape((10, 10)) im2 = im1.T im3 = np.flipud(im1) diff --git a/examples/axes_grid1/simple_axesgrid2.py b/examples/axes_grid1/simple_axesgrid2.py index 3adfe7cb4d9a..fce526fedb4c 100644 --- a/examples/axes_grid1/simple_axesgrid2.py +++ b/examples/axes_grid1/simple_axesgrid2.py @@ -7,10 +7,10 @@ `~mpl_toolkits.axes_grid1.axes_grid.ImageGrid`. """ -from matplotlib import cbook import matplotlib.pyplot as plt -from mpl_toolkits.axes_grid1 import ImageGrid +from matplotlib import cbook +from mpl_toolkits.axes_grid1 import ImageGrid fig = plt.figure(figsize=(5.5, 3.5)) grid = ImageGrid(fig, 111, # similar to subplot(111) diff --git a/examples/axes_grid1/simple_axisline4.py b/examples/axes_grid1/simple_axisline4.py index 4d93beb2b0d0..bbe6ef1c7970 100644 --- a/examples/axes_grid1/simple_axisline4.py +++ b/examples/axes_grid1/simple_axisline4.py @@ -5,9 +5,10 @@ """ import matplotlib.pyplot as plt -from mpl_toolkits.axes_grid1 import host_subplot import numpy as np +from mpl_toolkits.axes_grid1 import host_subplot + ax = host_subplot(111) xx = np.arange(0, 2*np.pi, 0.01) ax.plot(xx, np.sin(xx)) diff --git a/examples/axes_grid1/simple_colorbar.py b/examples/axes_grid1/simple_colorbar.py index 41a34eefcab1..5617cb0b6b4b 100644 --- a/examples/axes_grid1/simple_colorbar.py +++ b/examples/axes_grid1/simple_colorbar.py @@ -5,9 +5,10 @@ """ import matplotlib.pyplot as plt -from mpl_toolkits.axes_grid1 import make_axes_locatable import numpy as np +from mpl_toolkits.axes_grid1 import make_axes_locatable + ax = plt.subplot() im = ax.imshow(np.arange(100).reshape((10, 10))) diff --git a/examples/axisartist/axis_direction.py b/examples/axisartist/axis_direction.py index 7cf49f9cfa14..fbbbc5b93ce4 100644 --- a/examples/axisartist/axis_direction.py +++ b/examples/axisartist/axis_direction.py @@ -5,6 +5,7 @@ """ import matplotlib.pyplot as plt + import mpl_toolkits.axisartist as axisartist diff --git a/examples/axisartist/demo_axis_direction.py b/examples/axisartist/demo_axis_direction.py index f8c03205e732..f1d4593b3ab1 100644 --- a/examples/axisartist/demo_axis_direction.py +++ b/examples/axisartist/demo_axis_direction.py @@ -4,15 +4,14 @@ =================== """ -import numpy as np import matplotlib.pyplot as plt -import mpl_toolkits.axisartist.angle_helper as angle_helper -import mpl_toolkits.axisartist.grid_finder as grid_finder +import numpy as np + from matplotlib.projections import PolarAxes from matplotlib.transforms import Affine2D - import mpl_toolkits.axisartist as axisartist - +import mpl_toolkits.axisartist.angle_helper as angle_helper +import mpl_toolkits.axisartist.grid_finder as grid_finder from mpl_toolkits.axisartist.grid_helper_curvelinear import \ GridHelperCurveLinear diff --git a/examples/axisartist/demo_axisline_style.py b/examples/axisartist/demo_axisline_style.py index c7270941dadf..644864be8103 100644 --- a/examples/axisartist/demo_axisline_style.py +++ b/examples/axisartist/demo_axisline_style.py @@ -11,10 +11,10 @@ example. """ -from mpl_toolkits.axisartist.axislines import AxesZero import matplotlib.pyplot as plt import numpy as np +from mpl_toolkits.axisartist.axislines import AxesZero fig = plt.figure() ax = fig.add_subplot(axes_class=AxesZero) diff --git a/examples/axisartist/demo_curvelinear_grid.py b/examples/axisartist/demo_curvelinear_grid.py index 3efe83a43c70..76ade00ecb5e 100644 --- a/examples/axisartist/demo_curvelinear_grid.py +++ b/examples/axisartist/demo_curvelinear_grid.py @@ -11,15 +11,14 @@ shown on the second plot, to create polar projections in a rectangular box. """ +import matplotlib.pyplot as plt import numpy as np -import matplotlib.pyplot as plt from matplotlib.projections import PolarAxes from matplotlib.transforms import Affine2D - -from mpl_toolkits.axisartist import angle_helper, Axes, HostAxes -from mpl_toolkits.axisartist.grid_helper_curvelinear import ( - GridHelperCurveLinear) +from mpl_toolkits.axisartist import Axes, HostAxes, angle_helper +from mpl_toolkits.axisartist.grid_helper_curvelinear import \ + GridHelperCurveLinear def curvelinear_test1(fig): diff --git a/examples/axisartist/demo_curvelinear_grid2.py b/examples/axisartist/demo_curvelinear_grid2.py index 82944ef92575..4a8c115f196f 100644 --- a/examples/axisartist/demo_curvelinear_grid2.py +++ b/examples/axisartist/demo_curvelinear_grid2.py @@ -10,14 +10,14 @@ As showcase on the plot, a 5x5 matrix is displayed on the axes. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np -from mpl_toolkits.axisartist.grid_helper_curvelinear import ( - GridHelperCurveLinear) -from mpl_toolkits.axisartist.grid_finder import ( - ExtremeFinderSimple, MaxNLocator) from mpl_toolkits.axisartist.axislines import Axes +from mpl_toolkits.axisartist.grid_finder import (ExtremeFinderSimple, + MaxNLocator) +from mpl_toolkits.axisartist.grid_helper_curvelinear import \ + GridHelperCurveLinear def curvelinear_test1(fig): diff --git a/examples/axisartist/demo_floating_axes.py b/examples/axisartist/demo_floating_axes.py index 90e43f198127..87577b29c756 100644 --- a/examples/axisartist/demo_floating_axes.py +++ b/examples/axisartist/demo_floating_axes.py @@ -15,14 +15,15 @@ `~.floating_axes.GridHelperCurveLinear`. """ -from matplotlib.transforms import Affine2D -import mpl_toolkits.axisartist.floating_axes as floating_axes +import matplotlib.pyplot as plt import numpy as np -import mpl_toolkits.axisartist.angle_helper as angle_helper + from matplotlib.projections import PolarAxes -from mpl_toolkits.axisartist.grid_finder import (FixedLocator, MaxNLocator, - DictFormatter) -import matplotlib.pyplot as plt +from matplotlib.transforms import Affine2D +import mpl_toolkits.axisartist.angle_helper as angle_helper +import mpl_toolkits.axisartist.floating_axes as floating_axes +from mpl_toolkits.axisartist.grid_finder import (DictFormatter, FixedLocator, + MaxNLocator) # Fixing random state for reproducibility np.random.seed(19680801) diff --git a/examples/axisartist/demo_floating_axis.py b/examples/axisartist/demo_floating_axis.py index f607907c2654..0894bf8f4ce1 100644 --- a/examples/axisartist/demo_floating_axis.py +++ b/examples/axisartist/demo_floating_axis.py @@ -10,13 +10,13 @@ :doc:`/gallery/axisartist/demo_curvelinear_grid`. """ -import numpy as np import matplotlib.pyplot as plt -import mpl_toolkits.axisartist.angle_helper as angle_helper +import numpy as np + from matplotlib.projections import PolarAxes from matplotlib.transforms import Affine2D -from mpl_toolkits.axisartist import HostAxes -from mpl_toolkits.axisartist import GridHelperCurveLinear +from mpl_toolkits.axisartist import GridHelperCurveLinear, HostAxes +import mpl_toolkits.axisartist.angle_helper as angle_helper def curvelinear_test2(fig): diff --git a/examples/axisartist/demo_parasite_axes.py b/examples/axisartist/demo_parasite_axes.py index b1bdcbaba091..fb04e1e77873 100644 --- a/examples/axisartist/demo_parasite_axes.py +++ b/examples/axisartist/demo_parasite_axes.py @@ -18,9 +18,10 @@ :doc:`/gallery/axisartist/demo_parasite_axes2` example. """ -from mpl_toolkits.axisartist.parasite_axes import HostAxes import matplotlib.pyplot as plt +from mpl_toolkits.axisartist.parasite_axes import HostAxes + fig = plt.figure() host = fig.add_axes([0.15, 0.1, 0.65, 0.8], axes_class=HostAxes) diff --git a/examples/axisartist/demo_parasite_axes2.py b/examples/axisartist/demo_parasite_axes2.py index d72611c88cd5..a2e8bd30022e 100644 --- a/examples/axisartist/demo_parasite_axes2.py +++ b/examples/axisartist/demo_parasite_axes2.py @@ -23,10 +23,11 @@ :doc:`/gallery/axisartist/demo_parasite_axes` example. """ -from mpl_toolkits.axes_grid1 import host_subplot -from mpl_toolkits import axisartist import matplotlib.pyplot as plt +from mpl_toolkits import axisartist +from mpl_toolkits.axes_grid1 import host_subplot + host = host_subplot(111, axes_class=axisartist.Axes) plt.subplots_adjust(right=0.75) diff --git a/examples/axisartist/demo_ticklabel_alignment.py b/examples/axisartist/demo_ticklabel_alignment.py index e6d2d0c6ae59..b68b8263f2ed 100644 --- a/examples/axisartist/demo_ticklabel_alignment.py +++ b/examples/axisartist/demo_ticklabel_alignment.py @@ -7,6 +7,7 @@ import matplotlib.pyplot as plt + import mpl_toolkits.axisartist as axisartist diff --git a/examples/axisartist/demo_ticklabel_direction.py b/examples/axisartist/demo_ticklabel_direction.py index b15bf1b0590d..2248ea5234d7 100644 --- a/examples/axisartist/demo_ticklabel_direction.py +++ b/examples/axisartist/demo_ticklabel_direction.py @@ -6,6 +6,7 @@ """ import matplotlib.pyplot as plt + import mpl_toolkits.axisartist.axislines as axislines diff --git a/examples/axisartist/simple_axis_direction01.py b/examples/axisartist/simple_axis_direction01.py index 986ea690dfd4..68f5bdf3c6b8 100644 --- a/examples/axisartist/simple_axis_direction01.py +++ b/examples/axisartist/simple_axis_direction01.py @@ -5,6 +5,7 @@ """ import matplotlib.pyplot as plt + import mpl_toolkits.axisartist as axisartist fig = plt.figure(figsize=(4, 2.5)) diff --git a/examples/axisartist/simple_axis_direction03.py b/examples/axisartist/simple_axis_direction03.py index 29033601db3d..a600d8ac11c8 100644 --- a/examples/axisartist/simple_axis_direction03.py +++ b/examples/axisartist/simple_axis_direction03.py @@ -6,6 +6,7 @@ """ import matplotlib.pyplot as plt + import mpl_toolkits.axisartist as axisartist diff --git a/examples/axisartist/simple_axis_pad.py b/examples/axisartist/simple_axis_pad.py index a482c4728ada..7027a88d3549 100644 --- a/examples/axisartist/simple_axis_pad.py +++ b/examples/axisartist/simple_axis_pad.py @@ -5,15 +5,14 @@ """ -import numpy as np import matplotlib.pyplot as plt -import mpl_toolkits.axisartist.angle_helper as angle_helper -import mpl_toolkits.axisartist.grid_finder as grid_finder +import numpy as np + from matplotlib.projections import PolarAxes from matplotlib.transforms import Affine2D - import mpl_toolkits.axisartist as axisartist - +import mpl_toolkits.axisartist.angle_helper as angle_helper +import mpl_toolkits.axisartist.grid_finder as grid_finder from mpl_toolkits.axisartist.grid_helper_curvelinear import \ GridHelperCurveLinear diff --git a/examples/axisartist/simple_axisartist1.py b/examples/axisartist/simple_axisartist1.py index 95d710cbe0b1..80900dba5a97 100644 --- a/examples/axisartist/simple_axisartist1.py +++ b/examples/axisartist/simple_axisartist1.py @@ -14,9 +14,9 @@ """ import matplotlib.pyplot as plt -from mpl_toolkits import axisartist import numpy as np +from mpl_toolkits import axisartist fig = plt.figure(figsize=(6, 3), constrained_layout=True) # To construct axes of two different classes, we need to use gridspec (or diff --git a/examples/axisartist/simple_axisline.py b/examples/axisartist/simple_axisline.py index da0aad34a28a..10dab511c62c 100644 --- a/examples/axisartist/simple_axisline.py +++ b/examples/axisartist/simple_axisline.py @@ -6,8 +6,8 @@ """ import matplotlib.pyplot as plt -from mpl_toolkits.axisartist.axislines import AxesZero +from mpl_toolkits.axisartist.axislines import AxesZero fig = plt.figure() fig.subplots_adjust(right=0.85) diff --git a/examples/axisartist/simple_axisline3.py b/examples/axisartist/simple_axisline3.py index 41983cc04df3..9323674ff25a 100644 --- a/examples/axisartist/simple_axisline3.py +++ b/examples/axisartist/simple_axisline3.py @@ -5,6 +5,7 @@ """ import matplotlib.pyplot as plt + from mpl_toolkits.axisartist.axislines import Axes fig = plt.figure(figsize=(3, 3)) diff --git a/examples/color/color_by_yvalue.py b/examples/color/color_by_yvalue.py index a13796f50a82..c9bee252aec4 100644 --- a/examples/color/color_by_yvalue.py +++ b/examples/color/color_by_yvalue.py @@ -5,8 +5,8 @@ Use masked arrays to plot a line with different colors by y-value. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np t = np.arange(0.0, 2.0, 0.01) s = np.sin(2 * np.pi * t) diff --git a/examples/color/color_cycle_default.py b/examples/color/color_cycle_default.py index 580909143d09..ea81aa4fb1e6 100644 --- a/examples/color/color_cycle_default.py +++ b/examples/color/color_cycle_default.py @@ -6,9 +6,8 @@ Display the colors from the default prop_cycle, which is obtained from the :doc:`rc parameters`. """ -import numpy as np import matplotlib.pyplot as plt - +import numpy as np prop_cycle = plt.rcParams['axes.prop_cycle'] colors = prop_cycle.by_key()['color'] diff --git a/examples/color/colorbar_basics.py b/examples/color/colorbar_basics.py index c1a911132552..30fb7ed3096b 100644 --- a/examples/color/colorbar_basics.py +++ b/examples/color/colorbar_basics.py @@ -8,8 +8,8 @@ and the axes to attach the colorbar to. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np # setup some generic data N = 37 diff --git a/examples/color/colormap_reference.py b/examples/color/colormap_reference.py index be497c48663e..09d4a1885116 100644 --- a/examples/color/colormap_reference.py +++ b/examples/color/colormap_reference.py @@ -14,8 +14,8 @@ colormaps. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np cmaps = [('Perceptually Uniform Sequential', [ 'viridis', 'plasma', 'inferno', 'magma', 'cividis']), diff --git a/examples/color/custom_cmap.py b/examples/color/custom_cmap.py index bf90cfa28298..da064401486e 100644 --- a/examples/color/custom_cmap.py +++ b/examples/color/custom_cmap.py @@ -95,9 +95,10 @@ ``y1[-1]`` are never used. """ +import matplotlib.pyplot as plt import numpy as np + import matplotlib as mpl -import matplotlib.pyplot as plt from matplotlib.colors import LinearSegmentedColormap # Make some illustrative fake data: diff --git a/examples/color/named_colors.py b/examples/color/named_colors.py index 35da0f41b4a6..9245bbb42727 100644 --- a/examples/color/named_colors.py +++ b/examples/color/named_colors.py @@ -19,9 +19,10 @@ import math -from matplotlib.patches import Rectangle import matplotlib.pyplot as plt + import matplotlib.colors as mcolors +from matplotlib.patches import Rectangle def plot_colortable(colors, *, ncols=4, sort_colors=True): diff --git a/examples/event_handling/coords_demo.py b/examples/event_handling/coords_demo.py index 38a5b77f68e4..a7d2d044fe3b 100644 --- a/examples/event_handling/coords_demo.py +++ b/examples/event_handling/coords_demo.py @@ -15,10 +15,11 @@ using the link at the bottom of the page. """ -from matplotlib.backend_bases import MouseButton import matplotlib.pyplot as plt import numpy as np +from matplotlib.backend_bases import MouseButton + t = np.arange(0.0, 1.0, 0.01) s = np.sin(2 * np.pi * t) fig, ax = plt.subplots() diff --git a/examples/event_handling/data_browser.py b/examples/event_handling/data_browser.py index 7e1a551ba8a8..c24c77ecc57f 100644 --- a/examples/event_handling/data_browser.py +++ b/examples/event_handling/data_browser.py @@ -90,6 +90,7 @@ def update(self): if __name__ == '__main__': import matplotlib.pyplot as plt + # Fixing random state for reproducibility np.random.seed(19680801) diff --git a/examples/event_handling/ginput_manual_clabel_sgskip.py b/examples/event_handling/ginput_manual_clabel_sgskip.py index c13e751eceb8..a4f4f670f620 100644 --- a/examples/event_handling/ginput_manual_clabel_sgskip.py +++ b/examples/event_handling/ginput_manual_clabel_sgskip.py @@ -17,8 +17,8 @@ import time -import numpy as np import matplotlib.pyplot as plt +import numpy as np def tellme(s): diff --git a/examples/event_handling/image_slices_viewer.py b/examples/event_handling/image_slices_viewer.py index 8a2860902bce..a9abe8070b64 100644 --- a/examples/event_handling/image_slices_viewer.py +++ b/examples/event_handling/image_slices_viewer.py @@ -15,8 +15,8 @@ using the link at the bottom of the page. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np class IndexTracker: diff --git a/examples/event_handling/keypress_demo.py b/examples/event_handling/keypress_demo.py index e71e7ad3dfc4..6342e113d241 100644 --- a/examples/event_handling/keypress_demo.py +++ b/examples/event_handling/keypress_demo.py @@ -14,8 +14,9 @@ using the link at the bottom of the page. """ import sys -import numpy as np + import matplotlib.pyplot as plt +import numpy as np def on_press(event): diff --git a/examples/event_handling/lasso_demo.py b/examples/event_handling/lasso_demo.py index cb9412079330..aaef1bdfffac 100644 --- a/examples/event_handling/lasso_demo.py +++ b/examples/event_handling/lasso_demo.py @@ -19,12 +19,14 @@ using the link at the bottom of the page. """ -from matplotlib import colors as mcolors, path -from matplotlib.collections import RegularPolyCollection import matplotlib.pyplot as plt -from matplotlib.widgets import Lasso import numpy as np +from matplotlib import colors as mcolors +from matplotlib import path +from matplotlib.collections import RegularPolyCollection +from matplotlib.widgets import Lasso + class Datum: colorin = mcolors.to_rgba("red") diff --git a/examples/event_handling/legend_picking.py b/examples/event_handling/legend_picking.py index a33b9ba2088a..79c27358a8ff 100644 --- a/examples/event_handling/legend_picking.py +++ b/examples/event_handling/legend_picking.py @@ -14,9 +14,8 @@ using the link at the bottom of the page. """ -import numpy as np import matplotlib.pyplot as plt - +import numpy as np t = np.linspace(0, 1) y1 = 2 * np.sin(2*np.pi*t) diff --git a/examples/event_handling/looking_glass.py b/examples/event_handling/looking_glass.py index 70fe4651f79d..6032b39b5b9e 100644 --- a/examples/event_handling/looking_glass.py +++ b/examples/event_handling/looking_glass.py @@ -13,8 +13,9 @@ You can copy and paste individual parts, or download the entire example using the link at the bottom of the page. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np + import matplotlib.patches as patches # Fixing random state for reproducibility diff --git a/examples/event_handling/path_editor.py b/examples/event_handling/path_editor.py index 972f581bf47b..d6e84b454008 100644 --- a/examples/event_handling/path_editor.py +++ b/examples/event_handling/path_editor.py @@ -17,12 +17,12 @@ using the link at the bottom of the page. """ +import matplotlib.pyplot as plt import numpy as np + from matplotlib.backend_bases import MouseButton -from matplotlib.path import Path from matplotlib.patches import PathPatch -import matplotlib.pyplot as plt - +from matplotlib.path import Path fig, ax = plt.subplots() diff --git a/examples/event_handling/pick_event_demo.py b/examples/event_handling/pick_event_demo.py index 14269a3e69b9..163aaf923d77 100644 --- a/examples/event_handling/pick_event_demo.py +++ b/examples/event_handling/pick_event_demo.py @@ -72,13 +72,13 @@ def pick_handler(event): """ import matplotlib.pyplot as plt -from matplotlib.lines import Line2D -from matplotlib.patches import Rectangle -from matplotlib.text import Text -from matplotlib.image import AxesImage import numpy as np from numpy.random import rand +from matplotlib.image import AxesImage +from matplotlib.lines import Line2D +from matplotlib.patches import Rectangle +from matplotlib.text import Text # Fixing random state for reproducibility np.random.seed(19680801) diff --git a/examples/event_handling/pick_event_demo2.py b/examples/event_handling/pick_event_demo2.py index 28cef31015ce..5efaecb0d341 100644 --- a/examples/event_handling/pick_event_demo2.py +++ b/examples/event_handling/pick_event_demo2.py @@ -15,9 +15,8 @@ You can copy and paste individual parts, or download the entire example using the link at the bottom of the page. """ -import numpy as np import matplotlib.pyplot as plt - +import numpy as np # Fixing random state for reproducibility np.random.seed(19680801) diff --git a/examples/event_handling/poly_editor.py b/examples/event_handling/poly_editor.py index 8779a243b925..5465cca0ed94 100644 --- a/examples/event_handling/poly_editor.py +++ b/examples/event_handling/poly_editor.py @@ -16,8 +16,9 @@ """ import numpy as np -from matplotlib.lines import Line2D + from matplotlib.artist import Artist +from matplotlib.lines import Line2D def dist_point_to_segment(p, s0, s1): @@ -186,6 +187,7 @@ def on_mouse_move(self, event): if __name__ == '__main__': import matplotlib.pyplot as plt + from matplotlib.patches import Polygon theta = np.arange(0, 2*np.pi, 0.1) diff --git a/examples/event_handling/pong_sgskip.py b/examples/event_handling/pong_sgskip.py index 23b330165b36..5b26c143e7ac 100644 --- a/examples/event_handling/pong_sgskip.py +++ b/examples/event_handling/pong_sgskip.py @@ -17,9 +17,10 @@ import time -import numpy as np import matplotlib.pyplot as plt -from numpy.random import randn, randint +import numpy as np +from numpy.random import randint, randn + from matplotlib.font_manager import FontProperties instructions = """ diff --git a/examples/event_handling/resample.py b/examples/event_handling/resample.py index c7f94f1b7629..c034254d060a 100644 --- a/examples/event_handling/resample.py +++ b/examples/event_handling/resample.py @@ -16,8 +16,8 @@ using the link at the bottom of the page. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np # A class that will downsample the data and recompute when zoomed. diff --git a/examples/event_handling/timers.py b/examples/event_handling/timers.py index 43330097cf87..bf60492e353f 100644 --- a/examples/event_handling/timers.py +++ b/examples/event_handling/timers.py @@ -14,9 +14,10 @@ You can copy and paste individual parts, or download the entire example using the link at the bottom of the page. """ +from datetime import datetime + import matplotlib.pyplot as plt import numpy as np -from datetime import datetime def update_title(axes): diff --git a/examples/event_handling/trifinder_event_demo.py b/examples/event_handling/trifinder_event_demo.py index 991c5c9a3a82..e5b70b42724e 100644 --- a/examples/event_handling/trifinder_event_demo.py +++ b/examples/event_handling/trifinder_event_demo.py @@ -16,10 +16,11 @@ using the link at the bottom of the page. """ import matplotlib.pyplot as plt -from matplotlib.tri import Triangulation -from matplotlib.patches import Polygon import numpy as np +from matplotlib.patches import Polygon +from matplotlib.tri import Triangulation + def update_polygon(tri): if tri == -1: diff --git a/examples/event_handling/viewlims.py b/examples/event_handling/viewlims.py index 134419300a68..b47e3b5b0801 100644 --- a/examples/event_handling/viewlims.py +++ b/examples/event_handling/viewlims.py @@ -14,8 +14,9 @@ You can copy and paste individual parts, or download the entire example using the link at the bottom of the page. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np + from matplotlib.patches import Rectangle diff --git a/examples/event_handling/zoom_window.py b/examples/event_handling/zoom_window.py index c10cd820aa47..b8ba4c1048a9 100644 --- a/examples/event_handling/zoom_window.py +++ b/examples/event_handling/zoom_window.py @@ -25,7 +25,6 @@ import matplotlib.pyplot as plt import numpy as np - # Fixing random state for reproducibility np.random.seed(19680801) diff --git a/examples/images_contours_and_fields/affine_image.py b/examples/images_contours_and_fields/affine_image.py index 9b8fe6e68c10..f56ebfbdf9d2 100644 --- a/examples/images_contours_and_fields/affine_image.py +++ b/examples/images_contours_and_fields/affine_image.py @@ -13,8 +13,9 @@ rectangle. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np + import matplotlib.transforms as mtransforms diff --git a/examples/images_contours_and_fields/barcode_demo.py b/examples/images_contours_and_fields/barcode_demo.py index 109878edc0e0..41ddd4aff25f 100644 --- a/examples/images_contours_and_fields/barcode_demo.py +++ b/examples/images_contours_and_fields/barcode_demo.py @@ -20,7 +20,6 @@ import matplotlib.pyplot as plt import numpy as np - code = np.array([ 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, diff --git a/examples/images_contours_and_fields/colormap_normalizations.py b/examples/images_contours_and_fields/colormap_normalizations.py index 1a4420c81de9..40fa620df7b3 100644 --- a/examples/images_contours_and_fields/colormap_normalizations.py +++ b/examples/images_contours_and_fields/colormap_normalizations.py @@ -8,8 +8,9 @@ .. redirect-from:: /gallery/userdemo/colormap_normalizations """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np + import matplotlib.colors as colors # %% diff --git a/examples/images_contours_and_fields/colormap_normalizations_symlognorm.py b/examples/images_contours_and_fields/colormap_normalizations_symlognorm.py index 22eecd7caa18..14d54d170e7a 100644 --- a/examples/images_contours_and_fields/colormap_normalizations_symlognorm.py +++ b/examples/images_contours_and_fields/colormap_normalizations_symlognorm.py @@ -18,8 +18,9 @@ # # See `~.colors.SymLogNorm`. -import numpy as np import matplotlib.pyplot as plt +import numpy as np + import matplotlib.colors as colors diff --git a/examples/images_contours_and_fields/contour_demo.py b/examples/images_contours_and_fields/contour_demo.py index 3716a00b844a..273460516c4c 100644 --- a/examples/images_contours_and_fields/contour_demo.py +++ b/examples/images_contours_and_fields/contour_demo.py @@ -10,10 +10,10 @@ `. """ -import numpy as np -import matplotlib.cm as cm import matplotlib.pyplot as plt +import numpy as np +import matplotlib.cm as cm delta = 0.025 x = np.arange(-3.0, 3.0, delta) diff --git a/examples/images_contours_and_fields/contour_image.py b/examples/images_contours_and_fields/contour_image.py index de21be680b66..e03ec7a0402e 100644 --- a/examples/images_contours_and_fields/contour_image.py +++ b/examples/images_contours_and_fields/contour_image.py @@ -15,6 +15,7 @@ """ import matplotlib.pyplot as plt import numpy as np + from matplotlib import cm # Default delta is large because that makes it fast, and it illustrates diff --git a/examples/images_contours_and_fields/contour_label_demo.py b/examples/images_contours_and_fields/contour_label_demo.py index e8d096eb615d..57f29c827757 100644 --- a/examples/images_contours_and_fields/contour_label_demo.py +++ b/examples/images_contours_and_fields/contour_label_demo.py @@ -10,9 +10,10 @@ `. """ +import matplotlib.pyplot as plt import numpy as np + import matplotlib.ticker as ticker -import matplotlib.pyplot as plt # %% # Define our surface diff --git a/examples/images_contours_and_fields/contourf_demo.py b/examples/images_contours_and_fields/contourf_demo.py index 6b579934678c..53161ee4bbf6 100644 --- a/examples/images_contours_and_fields/contourf_demo.py +++ b/examples/images_contours_and_fields/contourf_demo.py @@ -5,8 +5,8 @@ How to use the `.axes.Axes.contourf` method to create filled contour plots. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np origin = 'lower' diff --git a/examples/images_contours_and_fields/contourf_log.py b/examples/images_contours_and_fields/contourf_log.py index ae6b50dcd3f2..7d1a4828c113 100644 --- a/examples/images_contours_and_fields/contourf_log.py +++ b/examples/images_contours_and_fields/contourf_log.py @@ -9,7 +9,8 @@ import matplotlib.pyplot as plt import numpy as np from numpy import ma -from matplotlib import ticker, cm + +from matplotlib import cm, ticker N = 100 x = np.linspace(-3.0, 3.0, N) diff --git a/examples/images_contours_and_fields/contours_in_optimization_demo.py b/examples/images_contours_and_fields/contours_in_optimization_demo.py index 866ef0edd24d..23126e940889 100644 --- a/examples/images_contours_and_fields/contours_in_optimization_demo.py +++ b/examples/images_contours_and_fields/contours_in_optimization_demo.py @@ -20,8 +20,9 @@ """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np + from matplotlib import patheffects fig, ax = plt.subplots(figsize=(6, 6)) diff --git a/examples/images_contours_and_fields/demo_bboximage.py b/examples/images_contours_and_fields/demo_bboximage.py index 8e857e7a423d..660aa0a58523 100644 --- a/examples/images_contours_and_fields/demo_bboximage.py +++ b/examples/images_contours_and_fields/demo_bboximage.py @@ -8,13 +8,12 @@ bounding box as well as how to manually create a bounding box for the image. """ +import matplotlib.pyplot as plt import numpy as np -import matplotlib.pyplot as plt from matplotlib.image import BboxImage from matplotlib.transforms import Bbox, TransformedBbox - fig, (ax1, ax2) = plt.subplots(ncols=2) # ---------------------------- diff --git a/examples/images_contours_and_fields/figimage_demo.py b/examples/images_contours_and_fields/figimage_demo.py index 5811d345693b..c8fe44956a86 100644 --- a/examples/images_contours_and_fields/figimage_demo.py +++ b/examples/images_contours_and_fields/figimage_demo.py @@ -6,9 +6,8 @@ This illustrates placing images directly in the figure, with no Axes objects. """ -import numpy as np import matplotlib.pyplot as plt - +import numpy as np fig = plt.figure() Z = np.arange(10000).reshape((100, 100)) diff --git a/examples/images_contours_and_fields/image_annotated_heatmap.py b/examples/images_contours_and_fields/image_annotated_heatmap.py index 9abbdeae118f..1802af0e6823 100644 --- a/examples/images_contours_and_fields/image_annotated_heatmap.py +++ b/examples/images_contours_and_fields/image_annotated_heatmap.py @@ -37,10 +37,12 @@ # within each cell showing the value of that cell. +import matplotlib.pyplot as plt import numpy as np + import matplotlib import matplotlib as mpl -import matplotlib.pyplot as plt + # sphinx_gallery_thumbnail_number = 2 vegetables = ["cucumber", "tomato", "lettuce", "asparagus", diff --git a/examples/images_contours_and_fields/image_antialiasing.py b/examples/images_contours_and_fields/image_antialiasing.py index 800f1848748e..e55275718c25 100644 --- a/examples/images_contours_and_fields/image_antialiasing.py +++ b/examples/images_contours_and_fields/image_antialiasing.py @@ -25,8 +25,8 @@ *interpolation* keyword argument. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np # %% # First we generate a 450x450 pixel image with varying frequency content: diff --git a/examples/images_contours_and_fields/image_clip_path.py b/examples/images_contours_and_fields/image_clip_path.py index a4f6737b22f4..d66ec535b1c3 100644 --- a/examples/images_contours_and_fields/image_clip_path.py +++ b/examples/images_contours_and_fields/image_clip_path.py @@ -6,9 +6,9 @@ Demo of image that's been clipped by a circular patch. """ import matplotlib.pyplot as plt -import matplotlib.patches as patches -import matplotlib.cbook as cbook +import matplotlib.cbook as cbook +import matplotlib.patches as patches with cbook.get_sample_data('grace_hopper.jpg') as image_file: image = plt.imread(image_file) diff --git a/examples/images_contours_and_fields/image_demo.py b/examples/images_contours_and_fields/image_demo.py index 774c379c1d95..295c48cf3bcd 100644 --- a/examples/images_contours_and_fields/image_demo.py +++ b/examples/images_contours_and_fields/image_demo.py @@ -10,13 +10,13 @@ functionality of imshow and the many images you can create. """ -import numpy as np -import matplotlib.cm as cm import matplotlib.pyplot as plt +import numpy as np + import matplotlib.cbook as cbook -from matplotlib.path import Path +import matplotlib.cm as cm from matplotlib.patches import PathPatch - +from matplotlib.path import Path # Fixing random state for reproducibility np.random.seed(19680801) diff --git a/examples/images_contours_and_fields/image_masked.py b/examples/images_contours_and_fields/image_masked.py index 0c97a01d3c95..d64ab2cff8c7 100644 --- a/examples/images_contours_and_fields/image_masked.py +++ b/examples/images_contours_and_fields/image_masked.py @@ -9,8 +9,9 @@ get a filled contour effect. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np + import matplotlib.colors as colors # compute some interesting data diff --git a/examples/images_contours_and_fields/image_nonuniform.py b/examples/images_contours_and_fields/image_nonuniform.py index 2b0c4fb8a798..b8f845ca1213 100644 --- a/examples/images_contours_and_fields/image_nonuniform.py +++ b/examples/images_contours_and_fields/image_nonuniform.py @@ -8,10 +8,11 @@ Axes instance as shown here. """ -import numpy as np import matplotlib.pyplot as plt -from matplotlib.image import NonUniformImage +import numpy as np + from matplotlib import cm +from matplotlib.image import NonUniformImage interp = 'nearest' diff --git a/examples/images_contours_and_fields/image_transparency_blend.py b/examples/images_contours_and_fields/image_transparency_blend.py index cb7b4f14e4dc..31d1d50f757c 100644 --- a/examples/images_contours_and_fields/image_transparency_blend.py +++ b/examples/images_contours_and_fields/image_transparency_blend.py @@ -15,9 +15,10 @@ in a 2D grid. One blob will be positive, and the other negative. """ +import matplotlib.pyplot as plt # sphinx_gallery_thumbnail_number = 3 import numpy as np -import matplotlib.pyplot as plt + from matplotlib.colors import Normalize diff --git a/examples/images_contours_and_fields/image_zcoord.py b/examples/images_contours_and_fields/image_zcoord.py index 1edcd90a0827..ffc336a653cc 100644 --- a/examples/images_contours_and_fields/image_zcoord.py +++ b/examples/images_contours_and_fields/image_zcoord.py @@ -8,8 +8,8 @@ just showcases how to customize the `~.axes.Axes.format_coord` function. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np # Fixing random state for reproducibility np.random.seed(19680801) diff --git a/examples/images_contours_and_fields/irregulardatagrid.py b/examples/images_contours_and_fields/irregulardatagrid.py index e3cbc9d03ade..d1c3e9b5e8a0 100644 --- a/examples/images_contours_and_fields/irregulardatagrid.py +++ b/examples/images_contours_and_fields/irregulardatagrid.py @@ -21,9 +21,10 @@ """ import matplotlib.pyplot as plt -import matplotlib.tri as tri import numpy as np +import matplotlib.tri as tri + np.random.seed(19680801) npts = 200 ngridx = 100 diff --git a/examples/images_contours_and_fields/multi_image.py b/examples/images_contours_and_fields/multi_image.py index ec7fbf0ce5cb..5634a32abeb9 100644 --- a/examples/images_contours_and_fields/multi_image.py +++ b/examples/images_contours_and_fields/multi_image.py @@ -6,10 +6,11 @@ Make a set of images with a single colormap, norm, and colorbar. """ -from matplotlib import colors import matplotlib.pyplot as plt import numpy as np +from matplotlib import colors + np.random.seed(19680801) Nr = 3 Nc = 2 diff --git a/examples/images_contours_and_fields/pcolor_demo.py b/examples/images_contours_and_fields/pcolor_demo.py index 847ccf2cfb2d..a783c83409df 100644 --- a/examples/images_contours_and_fields/pcolor_demo.py +++ b/examples/images_contours_and_fields/pcolor_demo.py @@ -10,8 +10,8 @@ """ import matplotlib.pyplot as plt import numpy as np -from matplotlib.colors import LogNorm +from matplotlib.colors import LogNorm # Fixing random state for reproducibility np.random.seed(19680801) diff --git a/examples/images_contours_and_fields/pcolormesh_levels.py b/examples/images_contours_and_fields/pcolormesh_levels.py index a9052b922d7b..23d47e5230d2 100644 --- a/examples/images_contours_and_fields/pcolormesh_levels.py +++ b/examples/images_contours_and_fields/pcolormesh_levels.py @@ -9,9 +9,10 @@ """ import matplotlib.pyplot as plt +import numpy as np + from matplotlib.colors import BoundaryNorm from matplotlib.ticker import MaxNLocator -import numpy as np # %% # Basic pcolormesh diff --git a/examples/images_contours_and_fields/plot_streamplot.py b/examples/images_contours_and_fields/plot_streamplot.py index 334d5ca0dc9b..402111b8199c 100644 --- a/examples/images_contours_and_fields/plot_streamplot.py +++ b/examples/images_contours_and_fields/plot_streamplot.py @@ -14,9 +14,8 @@ * Unbroken streamlines even when exceeding the limit of lines within a single grid cell. """ -import numpy as np import matplotlib.pyplot as plt - +import numpy as np w = 3 Y, X = np.mgrid[-w:w:100j, -w:w:100j] diff --git a/examples/images_contours_and_fields/quadmesh_demo.py b/examples/images_contours_and_fields/quadmesh_demo.py index 7f4dafbcf7b2..85876765834d 100644 --- a/examples/images_contours_and_fields/quadmesh_demo.py +++ b/examples/images_contours_and_fields/quadmesh_demo.py @@ -9,9 +9,10 @@ This demo illustrates a bug in quadmesh with masked data. """ -from matplotlib import pyplot as plt import numpy as np +from matplotlib import pyplot as plt + n = 12 x = np.linspace(-1.5, 1.5, n) y = np.linspace(-1.5, 1.5, n * 2) diff --git a/examples/images_contours_and_fields/shading_example.py b/examples/images_contours_and_fields/shading_example.py index 357eddd37ee3..08c491a28cf7 100644 --- a/examples/images_contours_and_fields/shading_example.py +++ b/examples/images_contours_and_fields/shading_example.py @@ -10,9 +10,10 @@ .. _Generic Mapping Tools: https://www.generic-mapping-tools.org/ """ +import matplotlib.pyplot as plt import numpy as np + from matplotlib import cbook -import matplotlib.pyplot as plt from matplotlib.colors import LightSource diff --git a/examples/images_contours_and_fields/spy_demos.py b/examples/images_contours_and_fields/spy_demos.py index 48347269e45f..ceb4b3d63e26 100644 --- a/examples/images_contours_and_fields/spy_demos.py +++ b/examples/images_contours_and_fields/spy_demos.py @@ -9,7 +9,6 @@ import matplotlib.pyplot as plt import numpy as np - # Fixing random state for reproducibility np.random.seed(19680801) diff --git a/examples/images_contours_and_fields/tricontour_demo.py b/examples/images_contours_and_fields/tricontour_demo.py index 7ae6ced22a17..3459382caad6 100644 --- a/examples/images_contours_and_fields/tricontour_demo.py +++ b/examples/images_contours_and_fields/tricontour_demo.py @@ -6,9 +6,10 @@ Contour plots of unstructured triangular grids. """ import matplotlib.pyplot as plt -import matplotlib.tri as tri import numpy as np +import matplotlib.tri as tri + # %% # Creating a Triangulation without specifying the triangles results in the # Delaunay triangulation of the points. diff --git a/examples/images_contours_and_fields/tricontour_smooth_delaunay.py b/examples/images_contours_and_fields/tricontour_smooth_delaunay.py index 3aacc6ad25c7..0f1ee4938f8d 100644 --- a/examples/images_contours_and_fields/tricontour_smooth_delaunay.py +++ b/examples/images_contours_and_fields/tricontour_smooth_delaunay.py @@ -23,10 +23,11 @@ 3. Plot the refined data with `~.axes.Axes.tricontour`. """ -from matplotlib.tri import Triangulation, TriAnalyzer, UniformTriRefiner import matplotlib.pyplot as plt import numpy as np +from matplotlib.tri import TriAnalyzer, Triangulation, UniformTriRefiner + # ---------------------------------------------------------------------------- # Analytical test function diff --git a/examples/images_contours_and_fields/tricontour_smooth_user.py b/examples/images_contours_and_fields/tricontour_smooth_user.py index e69aa332dd0e..2d973c0de108 100644 --- a/examples/images_contours_and_fields/tricontour_smooth_user.py +++ b/examples/images_contours_and_fields/tricontour_smooth_user.py @@ -6,10 +6,11 @@ Demonstrates high-resolution tricontouring on user-defined triangular grids with `matplotlib.tri.UniformTriRefiner`. """ -import matplotlib.tri as tri import matplotlib.pyplot as plt import numpy as np +import matplotlib.tri as tri + # ---------------------------------------------------------------------------- # Analytical test function diff --git a/examples/images_contours_and_fields/trigradient_demo.py b/examples/images_contours_and_fields/trigradient_demo.py index 21ecde0fedbf..aa3cbc889eba 100644 --- a/examples/images_contours_and_fields/trigradient_demo.py +++ b/examples/images_contours_and_fields/trigradient_demo.py @@ -6,11 +6,12 @@ Demonstrates computation of gradient with `matplotlib.tri.CubicTriInterpolator`. """ -from matplotlib.tri import ( - Triangulation, UniformTriRefiner, CubicTriInterpolator) import matplotlib.pyplot as plt import numpy as np +from matplotlib.tri import (CubicTriInterpolator, Triangulation, + UniformTriRefiner) + # ---------------------------------------------------------------------------- # Electrical potential of a dipole diff --git a/examples/images_contours_and_fields/triinterp_demo.py b/examples/images_contours_and_fields/triinterp_demo.py index 4f962ccdf767..a5bd31f775cd 100644 --- a/examples/images_contours_and_fields/triinterp_demo.py +++ b/examples/images_contours_and_fields/triinterp_demo.py @@ -6,9 +6,10 @@ Interpolation from triangular grid to quad grid. """ import matplotlib.pyplot as plt -import matplotlib.tri as mtri import numpy as np +import matplotlib.tri as mtri + # Create triangulation. x = np.asarray([0, 1, 2, 3, 0.5, 1.5, 2.5, 1, 2, 1.5]) y = np.asarray([0, 0, 0, 0, 1.0, 1.0, 1.0, 2, 2, 3.0]) diff --git a/examples/images_contours_and_fields/tripcolor_demo.py b/examples/images_contours_and_fields/tripcolor_demo.py index fac0f622f5ec..a1c011a1224c 100644 --- a/examples/images_contours_and_fields/tripcolor_demo.py +++ b/examples/images_contours_and_fields/tripcolor_demo.py @@ -6,9 +6,10 @@ Pseudocolor plots of unstructured triangular grids. """ import matplotlib.pyplot as plt -import matplotlib.tri as tri import numpy as np +import matplotlib.tri as tri + # %% # Creating a Triangulation without specifying the triangles results in the # Delaunay triangulation of the points. diff --git a/examples/images_contours_and_fields/triplot_demo.py b/examples/images_contours_and_fields/triplot_demo.py index 53a59a4e59f4..e1151b37ac4a 100644 --- a/examples/images_contours_and_fields/triplot_demo.py +++ b/examples/images_contours_and_fields/triplot_demo.py @@ -6,9 +6,10 @@ Creating and plotting unstructured triangular grids. """ import matplotlib.pyplot as plt -import matplotlib.tri as tri import numpy as np +import matplotlib.tri as tri + # %% # Creating a Triangulation without specifying the triangles results in the # Delaunay triangulation of the points. diff --git a/examples/images_contours_and_fields/watermark_image.py b/examples/images_contours_and_fields/watermark_image.py index cf850cbd77a8..a68b47b125d8 100644 --- a/examples/images_contours_and_fields/watermark_image.py +++ b/examples/images_contours_and_fields/watermark_image.py @@ -6,11 +6,11 @@ Using a PNG file as a watermark. """ +import matplotlib.pyplot as plt import numpy as np + import matplotlib.cbook as cbook import matplotlib.image as image -import matplotlib.pyplot as plt - with cbook.get_sample_data('logo2.png') as file: im = image.imread(file) diff --git a/examples/lines_bars_and_markers/capstyle.py b/examples/lines_bars_and_markers/capstyle.py index 05bb1e96585c..f573aaa871b8 100644 --- a/examples/lines_bars_and_markers/capstyle.py +++ b/examples/lines_bars_and_markers/capstyle.py @@ -9,6 +9,7 @@ """ import matplotlib.pyplot as plt + from matplotlib._enums import CapStyle CapStyle.demo() diff --git a/examples/lines_bars_and_markers/cohere.py b/examples/lines_bars_and_markers/cohere.py index 7881a0a31b1e..cd6a11566afa 100644 --- a/examples/lines_bars_and_markers/cohere.py +++ b/examples/lines_bars_and_markers/cohere.py @@ -5,8 +5,8 @@ An example showing how to plot the coherence of two signals. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np # Fixing random state for reproducibility np.random.seed(19680801) diff --git a/examples/lines_bars_and_markers/csd_demo.py b/examples/lines_bars_and_markers/csd_demo.py index 8894333f94d0..8bba858df574 100644 --- a/examples/lines_bars_and_markers/csd_demo.py +++ b/examples/lines_bars_and_markers/csd_demo.py @@ -5,9 +5,8 @@ Compute the cross spectral density of two signals """ -import numpy as np import matplotlib.pyplot as plt - +import numpy as np fig, (ax1, ax2) = plt.subplots(2, 1) # make a little extra space between the subplots diff --git a/examples/lines_bars_and_markers/curve_error_band.py b/examples/lines_bars_and_markers/curve_error_band.py index 59db81a7d259..b3d7292b1292 100644 --- a/examples/lines_bars_and_markers/curve_error_band.py +++ b/examples/lines_bars_and_markers/curve_error_band.py @@ -9,11 +9,11 @@ """ # sphinx_gallery_thumbnail_number = 2 +import matplotlib.pyplot as plt import numpy as np -import matplotlib.pyplot as plt -from matplotlib.path import Path from matplotlib.patches import PathPatch +from matplotlib.path import Path N = 400 t = np.linspace(0, 2 * np.pi, N) diff --git a/examples/lines_bars_and_markers/errorbar_limits_simple.py b/examples/lines_bars_and_markers/errorbar_limits_simple.py index 7727137046b3..aff01eece49a 100644 --- a/examples/lines_bars_and_markers/errorbar_limits_simple.py +++ b/examples/lines_bars_and_markers/errorbar_limits_simple.py @@ -9,9 +9,8 @@ Alternatively, you can use 2xN values to draw errorbars in only one direction. """ -import numpy as np import matplotlib.pyplot as plt - +import numpy as np fig = plt.figure() x = np.arange(10) diff --git a/examples/lines_bars_and_markers/errorbar_subsample.py b/examples/lines_bars_and_markers/errorbar_subsample.py index a4a9453691db..e5aa84577231 100644 --- a/examples/lines_bars_and_markers/errorbar_subsample.py +++ b/examples/lines_bars_and_markers/errorbar_subsample.py @@ -8,8 +8,8 @@ data points with similar errors. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np # example data x = np.arange(0.1, 4, 0.1) diff --git a/examples/lines_bars_and_markers/eventcollection_demo.py b/examples/lines_bars_and_markers/eventcollection_demo.py index e4fe6f61bdab..f82fb829c248 100644 --- a/examples/lines_bars_and_markers/eventcollection_demo.py +++ b/examples/lines_bars_and_markers/eventcollection_demo.py @@ -8,9 +8,10 @@ """ import matplotlib.pyplot as plt -from matplotlib.collections import EventCollection import numpy as np +from matplotlib.collections import EventCollection + # Fixing random state for reproducibility np.random.seed(19680801) diff --git a/examples/lines_bars_and_markers/eventplot_demo.py b/examples/lines_bars_and_markers/eventplot_demo.py index 44e3c183bb51..b76999ef05d5 100644 --- a/examples/lines_bars_and_markers/eventplot_demo.py +++ b/examples/lines_bars_and_markers/eventplot_demo.py @@ -9,7 +9,9 @@ import matplotlib.pyplot as plt import numpy as np + import matplotlib + matplotlib.rcParams['font.size'] = 8.0 # Fixing random state for reproducibility diff --git a/examples/lines_bars_and_markers/fill.py b/examples/lines_bars_and_markers/fill.py index cba430153763..a9cba03c273c 100644 --- a/examples/lines_bars_and_markers/fill.py +++ b/examples/lines_bars_and_markers/fill.py @@ -12,8 +12,8 @@ """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np def koch_snowflake(order, scale=10): diff --git a/examples/lines_bars_and_markers/fill_between_alpha.py b/examples/lines_bars_and_markers/fill_between_alpha.py index 235c4c6091fc..e58fdfdfe12c 100644 --- a/examples/lines_bars_and_markers/fill_between_alpha.py +++ b/examples/lines_bars_and_markers/fill_between_alpha.py @@ -14,8 +14,8 @@ import matplotlib.pyplot as plt import numpy as np -import matplotlib.cbook as cbook +import matplotlib.cbook as cbook # load up some sample financial data r = (cbook.get_sample_data('goog.npz', np_load=True)['price_data'] diff --git a/examples/lines_bars_and_markers/fill_betweenx_demo.py b/examples/lines_bars_and_markers/fill_betweenx_demo.py index 91650c3698c9..b311db42af85 100644 --- a/examples/lines_bars_and_markers/fill_betweenx_demo.py +++ b/examples/lines_bars_and_markers/fill_betweenx_demo.py @@ -9,7 +9,6 @@ import matplotlib.pyplot as plt import numpy as np - y = np.arange(0.0, 2, 0.01) x1 = np.sin(2 * np.pi * y) x2 = 1.2 * np.sin(4 * np.pi * y) diff --git a/examples/lines_bars_and_markers/filled_step.py b/examples/lines_bars_and_markers/filled_step.py index 5edd7462cf15..abc806fc5acf 100644 --- a/examples/lines_bars_and_markers/filled_step.py +++ b/examples/lines_bars_and_markers/filled_step.py @@ -6,13 +6,15 @@ Hatching capabilities for plotting histograms. """ -import itertools from functools import partial +import itertools + +from cycler import cycler -import numpy as np import matplotlib.pyplot as plt +import numpy as np + import matplotlib.ticker as mticker -from cycler import cycler def filled_hist(ax, edges, values, bottoms=None, orientation='v', diff --git a/examples/lines_bars_and_markers/hat_graph.py b/examples/lines_bars_and_markers/hat_graph.py index ddef3e9f631f..0091c3c95d51 100644 --- a/examples/lines_bars_and_markers/hat_graph.py +++ b/examples/lines_bars_and_markers/hat_graph.py @@ -7,8 +7,8 @@ .. _hat graph: https://doi.org/10.1186/s41235-019-0182-3 """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np def hat_graph(ax, xlabels, values, group_labels): diff --git a/examples/lines_bars_and_markers/horizontal_barchart_distribution.py b/examples/lines_bars_and_markers/horizontal_barchart_distribution.py index 778391920936..ae638a90c3fd 100644 --- a/examples/lines_bars_and_markers/horizontal_barchart_distribution.py +++ b/examples/lines_bars_and_markers/horizontal_barchart_distribution.py @@ -13,9 +13,8 @@ already drawn bars via the parameter ``left``. """ -import numpy as np import matplotlib.pyplot as plt - +import numpy as np category_names = ['Strongly disagree', 'Disagree', 'Neither agree nor disagree', 'Agree', 'Strongly agree'] diff --git a/examples/lines_bars_and_markers/joinstyle.py b/examples/lines_bars_and_markers/joinstyle.py index 0f289d7ac393..27ad9ede96b1 100644 --- a/examples/lines_bars_and_markers/joinstyle.py +++ b/examples/lines_bars_and_markers/joinstyle.py @@ -9,6 +9,7 @@ """ import matplotlib.pyplot as plt + from matplotlib._enums import JoinStyle JoinStyle.demo() diff --git a/examples/lines_bars_and_markers/line_demo_dash_control.py b/examples/lines_bars_and_markers/line_demo_dash_control.py index 9d02981597c0..abd8d6750e70 100644 --- a/examples/lines_bars_and_markers/line_demo_dash_control.py +++ b/examples/lines_bars_and_markers/line_demo_dash_control.py @@ -23,8 +23,8 @@ `~.Line2D.set_gapcolor`) or by passing the property through a plotting function. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np x = np.linspace(0, 10, 500) y = np.sin(x) diff --git a/examples/lines_bars_and_markers/lines_with_ticks_demo.py b/examples/lines_bars_and_markers/lines_with_ticks_demo.py index f7ef646c647f..00776d89caff 100644 --- a/examples/lines_bars_and_markers/lines_with_ticks_demo.py +++ b/examples/lines_bars_and_markers/lines_with_ticks_demo.py @@ -11,8 +11,9 @@ """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np + from matplotlib import patheffects # Plot a straight diagonal line with ticked style path diff --git a/examples/lines_bars_and_markers/linestyles.py b/examples/lines_bars_and_markers/linestyles.py index 96c9113ee4cc..cf4bfa0eb3a6 100644 --- a/examples/lines_bars_and_markers/linestyles.py +++ b/examples/lines_bars_and_markers/linestyles.py @@ -15,8 +15,8 @@ and passing a list of dash sequences using the keyword *dashes* to the cycler in :doc:`property_cycle `. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np linestyle_str = [ ('solid', 'solid'), # Same as (0, ()) or '-' diff --git a/examples/lines_bars_and_markers/marker_reference.py b/examples/lines_bars_and_markers/marker_reference.py index 6d2eb77544e8..557f988b7c0c 100644 --- a/examples/lines_bars_and_markers/marker_reference.py +++ b/examples/lines_bars_and_markers/marker_reference.py @@ -19,12 +19,12 @@ .. redirect-from:: /gallery/shapes_and_collections/marker_path """ -from matplotlib.markers import MarkerStyle import matplotlib.pyplot as plt + from matplotlib.lines import Line2D +from matplotlib.markers import MarkerStyle from matplotlib.transforms import Affine2D - text_style = dict(horizontalalignment='right', verticalalignment='center', fontsize=12, fontfamily='monospace') marker_style = dict(linestyle=':', color='0.8', markersize=10, @@ -128,9 +128,10 @@ def split_list(a_list): # simple paths *star* and *circle*, and a more elaborate path of a circle with # a cut-out star. -import matplotlib.path as mpath import numpy as np +import matplotlib.path as mpath + star = mpath.Path.unit_regular_star(6) circle = mpath.Path.unit_circle() # concatenate the circle with an internal cutout of the star @@ -192,7 +193,7 @@ def split_list(a_list): # Markers have default cap and join styles, but these can be # customized when creating a MarkerStyle. -from matplotlib.markers import JoinStyle, CapStyle +from matplotlib.markers import CapStyle, JoinStyle marker_inner = dict(markersize=35, markerfacecolor='tab:blue', diff --git a/examples/lines_bars_and_markers/markevery_demo.py b/examples/lines_bars_and_markers/markevery_demo.py index fc88db03cbf5..974fee378bbf 100644 --- a/examples/lines_bars_and_markers/markevery_demo.py +++ b/examples/lines_bars_and_markers/markevery_demo.py @@ -19,8 +19,8 @@ of the points along the line, irrespective of scales and zooming. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np # define a list of markevery cases to plot cases = [ diff --git a/examples/lines_bars_and_markers/masked_demo.py b/examples/lines_bars_and_markers/masked_demo.py index 1f94a4f61891..a0b63ae30fe4 100644 --- a/examples/lines_bars_and_markers/masked_demo.py +++ b/examples/lines_bars_and_markers/masked_demo.py @@ -27,7 +27,6 @@ import matplotlib.pyplot as plt import numpy as np - x = np.linspace(-np.pi/2, np.pi/2, 31) y = np.cos(x)**3 diff --git a/examples/lines_bars_and_markers/multicolored_line.py b/examples/lines_bars_and_markers/multicolored_line.py index da15a570686b..5d0727e69181 100644 --- a/examples/lines_bars_and_markers/multicolored_line.py +++ b/examples/lines_bars_and_markers/multicolored_line.py @@ -7,10 +7,11 @@ is colored based on its derivative. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np + from matplotlib.collections import LineCollection -from matplotlib.colors import ListedColormap, BoundaryNorm +from matplotlib.colors import BoundaryNorm, ListedColormap x = np.linspace(0, 3 * np.pi, 500) y = np.sin(x) diff --git a/examples/lines_bars_and_markers/multivariate_marker_plot.py b/examples/lines_bars_and_markers/multivariate_marker_plot.py index 7627375b99f5..13609422e690 100644 --- a/examples/lines_bars_and_markers/multivariate_marker_plot.py +++ b/examples/lines_bars_and_markers/multivariate_marker_plot.py @@ -9,12 +9,13 @@ the take-off angle, and thrust to the marker color. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np + +from matplotlib.colors import Normalize from matplotlib.markers import MarkerStyle -from matplotlib.transforms import Affine2D from matplotlib.text import TextPath -from matplotlib.colors import Normalize +from matplotlib.transforms import Affine2D SUCCESS_SYMBOLS = [ TextPath((0, 0), "☹"), diff --git a/examples/lines_bars_and_markers/psd_demo.py b/examples/lines_bars_and_markers/psd_demo.py index 5d30c6a784f6..774fe73d316d 100644 --- a/examples/lines_bars_and_markers/psd_demo.py +++ b/examples/lines_bars_and_markers/psd_demo.py @@ -11,6 +11,7 @@ """ import matplotlib.pyplot as plt import numpy as np + import matplotlib.mlab as mlab # Fixing random state for reproducibility diff --git a/examples/lines_bars_and_markers/scatter_demo2.py b/examples/lines_bars_and_markers/scatter_demo2.py index ec7e8183f8c4..bd7d94a5ad76 100644 --- a/examples/lines_bars_and_markers/scatter_demo2.py +++ b/examples/lines_bars_and_markers/scatter_demo2.py @@ -5,8 +5,9 @@ Demo of scatter plot with varying marker colors and sizes. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np + import matplotlib.cbook as cbook # Load a numpy record array from yahoo csv data with fields date, open, high, diff --git a/examples/lines_bars_and_markers/scatter_hist.py b/examples/lines_bars_and_markers/scatter_hist.py index 15225430d271..5d3c7070cf83 100644 --- a/examples/lines_bars_and_markers/scatter_hist.py +++ b/examples/lines_bars_and_markers/scatter_hist.py @@ -25,8 +25,8 @@ then create the scatter and histograms inside the provided axes. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np # Fixing random state for reproducibility np.random.seed(19680801) diff --git a/examples/lines_bars_and_markers/scatter_star_poly.py b/examples/lines_bars_and_markers/scatter_star_poly.py index 53089c2819a6..8f00ceccf4c1 100644 --- a/examples/lines_bars_and_markers/scatter_star_poly.py +++ b/examples/lines_bars_and_markers/scatter_star_poly.py @@ -7,8 +7,8 @@ For a list of all markers see also the `matplotlib.markers` documentation. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np # Fixing random state for reproducibility np.random.seed(19680801) diff --git a/examples/lines_bars_and_markers/scatter_with_legend.py b/examples/lines_bars_and_markers/scatter_with_legend.py index 133115489364..786ffff18807 100644 --- a/examples/lines_bars_and_markers/scatter_with_legend.py +++ b/examples/lines_bars_and_markers/scatter_with_legend.py @@ -11,8 +11,8 @@ can be adjusted by giving ``alpha`` a value between 0 and 1. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np np.random.seed(19680801) diff --git a/examples/lines_bars_and_markers/span_regions.py b/examples/lines_bars_and_markers/span_regions.py index 073f4a02aae6..e73b1af47baa 100644 --- a/examples/lines_bars_and_markers/span_regions.py +++ b/examples/lines_bars_and_markers/span_regions.py @@ -4,9 +4,8 @@ ========================================================== """ -import numpy as np import matplotlib.pyplot as plt - +import numpy as np t = np.arange(0.0, 2, 0.01) s = np.sin(2*np.pi*t) diff --git a/examples/lines_bars_and_markers/spectrum_demo.py b/examples/lines_bars_and_markers/spectrum_demo.py index 0b1b9d8e05e9..6f9ba3e1d7d0 100644 --- a/examples/lines_bars_and_markers/spectrum_demo.py +++ b/examples/lines_bars_and_markers/spectrum_demo.py @@ -10,7 +10,6 @@ import matplotlib.pyplot as plt import numpy as np - np.random.seed(0) dt = 0.01 # sampling interval diff --git a/examples/lines_bars_and_markers/stackplot_demo.py b/examples/lines_bars_and_markers/stackplot_demo.py index f52bb9fabac6..958fab67c7d5 100644 --- a/examples/lines_bars_and_markers/stackplot_demo.py +++ b/examples/lines_bars_and_markers/stackplot_demo.py @@ -13,8 +13,8 @@ # value are of interest. -import numpy as np import matplotlib.pyplot as plt +import numpy as np # data from United Nations World Population Prospects (Revision 2019) # https://population.un.org/wpp/, license: CC BY 3.0 IGO diff --git a/examples/lines_bars_and_markers/stairs_demo.py b/examples/lines_bars_and_markers/stairs_demo.py index 040d12f4a10d..223e8c2aa1e5 100644 --- a/examples/lines_bars_and_markers/stairs_demo.py +++ b/examples/lines_bars_and_markers/stairs_demo.py @@ -9,8 +9,9 @@ """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np + from matplotlib.patches import StepPatch np.random.seed(0) diff --git a/examples/lines_bars_and_markers/step_demo.py b/examples/lines_bars_and_markers/step_demo.py index 11954c6872cb..97d2a37eb4c6 100644 --- a/examples/lines_bars_and_markers/step_demo.py +++ b/examples/lines_bars_and_markers/step_demo.py @@ -16,8 +16,8 @@ positions so that it's easier to see the effect of *where*. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np x = np.arange(14) y = np.sin(x / 2) diff --git a/examples/lines_bars_and_markers/timeline.py b/examples/lines_bars_and_markers/timeline.py index c50b06387fc8..6eb62d38190e 100644 --- a/examples/lines_bars_and_markers/timeline.py +++ b/examples/lines_bars_and_markers/timeline.py @@ -10,16 +10,18 @@ of Matplotlib. First, we'll pull the data from GitHub. """ +from datetime import datetime + import matplotlib.pyplot as plt import numpy as np + import matplotlib.dates as mdates -from datetime import datetime try: # Try to fetch a list of Matplotlib releases and their dates # from https://api.github.com/repos/matplotlib/matplotlib/releases - import urllib.request import json + import urllib.request url = 'https://api.github.com/repos/matplotlib/matplotlib/releases' url += '?per_page=100' diff --git a/examples/lines_bars_and_markers/vline_hline_demo.py b/examples/lines_bars_and_markers/vline_hline_demo.py index 95616600573e..564d44ce7401 100644 --- a/examples/lines_bars_and_markers/vline_hline_demo.py +++ b/examples/lines_bars_and_markers/vline_hline_demo.py @@ -9,7 +9,6 @@ import matplotlib.pyplot as plt import numpy as np - # Fixing random state for reproducibility np.random.seed(19680801) diff --git a/examples/lines_bars_and_markers/xcorr_acorr_demo.py b/examples/lines_bars_and_markers/xcorr_acorr_demo.py index 933f21054867..6789f65bf6d6 100644 --- a/examples/lines_bars_and_markers/xcorr_acorr_demo.py +++ b/examples/lines_bars_and_markers/xcorr_acorr_demo.py @@ -9,7 +9,6 @@ import matplotlib.pyplot as plt import numpy as np - # Fixing random state for reproducibility np.random.seed(19680801) diff --git a/examples/misc/anchored_artists.py b/examples/misc/anchored_artists.py index 101c692ced3a..5ea3dae6b2e1 100644 --- a/examples/misc/anchored_artists.py +++ b/examples/misc/anchored_artists.py @@ -17,9 +17,9 @@ from matplotlib import pyplot as plt from matplotlib.lines import Line2D +from matplotlib.offsetbox import (AnchoredOffsetbox, AuxTransformBox, + DrawingArea, TextArea, VPacker) from matplotlib.patches import Circle, Ellipse -from matplotlib.offsetbox import ( - AnchoredOffsetbox, AuxTransformBox, DrawingArea, TextArea, VPacker) def draw_text(ax): diff --git a/examples/misc/bbox_intersect.py b/examples/misc/bbox_intersect.py index e7343fb628ad..c645cd34c155 100644 --- a/examples/misc/bbox_intersect.py +++ b/examples/misc/bbox_intersect.py @@ -8,10 +8,11 @@ """ -import numpy as np import matplotlib.pyplot as plt -from matplotlib.transforms import Bbox +import numpy as np + from matplotlib.path import Path +from matplotlib.transforms import Bbox # Fixing random state for reproducibility np.random.seed(19680801) diff --git a/examples/misc/contour_manual.py b/examples/misc/contour_manual.py index 4cde4f0ad6ef..c999f3f61ddb 100644 --- a/examples/misc/contour_manual.py +++ b/examples/misc/contour_manual.py @@ -6,9 +6,9 @@ Example of displaying your own contour lines and polygons using ContourSet. """ import matplotlib.pyplot as plt -from matplotlib.contour import ContourSet -import matplotlib.cm as cm +import matplotlib.cm as cm +from matplotlib.contour import ContourSet # %% # Contour lines for each level are a list/tuple of polygons. diff --git a/examples/misc/custom_projection.py b/examples/misc/custom_projection.py index c5c13e174087..e63ba8771ee1 100644 --- a/examples/misc/custom_projection.py +++ b/examples/misc/custom_projection.py @@ -6,16 +6,17 @@ Showcase Hammer projection by alleviating many features of Matplotlib. """ +import numpy as np + import matplotlib from matplotlib.axes import Axes +import matplotlib.axis as maxis from matplotlib.patches import Circle from matplotlib.path import Path -from matplotlib.ticker import NullLocator, Formatter, FixedLocator -from matplotlib.transforms import Affine2D, BboxTransformTo, Transform from matplotlib.projections import register_projection import matplotlib.spines as mspines -import matplotlib.axis as maxis -import numpy as np +from matplotlib.ticker import FixedLocator, Formatter, NullLocator +from matplotlib.transforms import Affine2D, BboxTransformTo, Transform rcParams = matplotlib.rcParams @@ -436,6 +437,7 @@ def _get_core_transform(self, resolution): if __name__ == '__main__': import matplotlib.pyplot as plt + # Now make a simple example using the custom projection. fig, ax = plt.subplots(subplot_kw={'projection': 'custom_hammer'}) ax.plot([-1, 1, 1], [-1, -1, 1], "o-") diff --git a/examples/misc/demo_agg_filter.py b/examples/misc/demo_agg_filter.py index 0cdbf81f50b5..5c2ad71a6673 100644 --- a/examples/misc/demo_agg_filter.py +++ b/examples/misc/demo_agg_filter.py @@ -10,13 +10,14 @@ .. _Anti-Grain Geometry (AGG): http://agg.sourceforge.net/antigrain.com """ -import matplotlib.cm as cm import matplotlib.pyplot as plt -import matplotlib.transforms as mtransforms -from matplotlib.colors import LightSource -from matplotlib.artist import Artist import numpy as np +from matplotlib.artist import Artist +import matplotlib.cm as cm +from matplotlib.colors import LightSource +import matplotlib.transforms as mtransforms + def smooth1d(x, window_len): # copied from https://scipy-cookbook.readthedocs.io/items/SignalSmooth.html diff --git a/examples/misc/demo_ribbon_box.py b/examples/misc/demo_ribbon_box.py index ea4fa579e8c5..f99ed22adf64 100644 --- a/examples/misc/demo_ribbon_box.py +++ b/examples/misc/demo_ribbon_box.py @@ -5,12 +5,13 @@ """ +import matplotlib.pyplot as plt import numpy as np -from matplotlib import cbook, colors as mcolors +from matplotlib import cbook +from matplotlib import colors as mcolors from matplotlib.image import AxesImage -import matplotlib.pyplot as plt -from matplotlib.transforms import Bbox, TransformedBbox, BboxTransformTo +from matplotlib.transforms import Bbox, BboxTransformTo, TransformedBbox class RibbonBox: diff --git a/examples/misc/fig_x.py b/examples/misc/fig_x.py index 2ef1e8d9a709..2985c2f1cffc 100644 --- a/examples/misc/fig_x.py +++ b/examples/misc/fig_x.py @@ -9,8 +9,8 @@ """ import matplotlib.pyplot as plt -import matplotlib.lines as lines +import matplotlib.lines as lines fig = plt.figure() fig.add_artist(lines.Line2D([0, 1], [0, 1])) diff --git a/examples/misc/findobj_demo.py b/examples/misc/findobj_demo.py index 971a184a53de..c953040f8aa3 100644 --- a/examples/misc/findobj_demo.py +++ b/examples/misc/findobj_demo.py @@ -5,8 +5,9 @@ Recursively find all objects that match some criteria """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np + import matplotlib.text as text a = np.arange(0, 3, .02) diff --git a/examples/misc/font_indexing.py b/examples/misc/font_indexing.py index f629306c0aae..02d77e647bf3 100644 --- a/examples/misc/font_indexing.py +++ b/examples/misc/font_indexing.py @@ -9,9 +9,8 @@ import os import matplotlib -from matplotlib.ft2font import ( - FT2Font, KERNING_DEFAULT, KERNING_UNFITTED, KERNING_UNSCALED) - +from matplotlib.ft2font import (KERNING_DEFAULT, KERNING_UNFITTED, + KERNING_UNSCALED, FT2Font) font = FT2Font( os.path.join(matplotlib.get_data_path(), 'fonts/ttf/DejaVuSans.ttf')) diff --git a/examples/misc/ftface_props.py b/examples/misc/ftface_props.py index 72ef8c61b10f..0cdf363fb6ba 100644 --- a/examples/misc/ftface_props.py +++ b/examples/misc/ftface_props.py @@ -13,7 +13,6 @@ import matplotlib import matplotlib.ft2font as ft - font = ft.FT2Font( # Use a font shipped with Matplotlib. os.path.join(matplotlib.get_data_path(), diff --git a/examples/misc/histogram_path.py b/examples/misc/histogram_path.py index 3de9e07b4813..55260f9699bb 100644 --- a/examples/misc/histogram_path.py +++ b/examples/misc/histogram_path.py @@ -14,8 +14,9 @@ for large numbers of objects. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np + import matplotlib.patches as patches import matplotlib.path as path diff --git a/examples/misc/hyperlinks_sgskip.py b/examples/misc/hyperlinks_sgskip.py index 6528cc2d44eb..8ecef0a9e3ca 100644 --- a/examples/misc/hyperlinks_sgskip.py +++ b/examples/misc/hyperlinks_sgskip.py @@ -10,9 +10,10 @@ """ +import matplotlib.pyplot as plt import numpy as np + import matplotlib.cm as cm -import matplotlib.pyplot as plt # %% diff --git a/examples/misc/image_thumbnail_sgskip.py b/examples/misc/image_thumbnail_sgskip.py index 68e3ba85ed38..edc1e5aa3573 100644 --- a/examples/misc/image_thumbnail_sgskip.py +++ b/examples/misc/image_thumbnail_sgskip.py @@ -13,8 +13,8 @@ from argparse import ArgumentParser from pathlib import Path import sys -import matplotlib.image as image +import matplotlib.image as image parser = ArgumentParser( description="Build thumbnails of all images in a directory.") diff --git a/examples/misc/keyword_plotting.py b/examples/misc/keyword_plotting.py index 7c8182330aed..4e0f3e61037d 100644 --- a/examples/misc/keyword_plotting.py +++ b/examples/misc/keyword_plotting.py @@ -12,8 +12,9 @@ corresponding to these variables. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np + np.random.seed(19680801) data = {'a': np.arange(50), diff --git a/examples/misc/logos2.py b/examples/misc/logos2.py index 03b18305e0ee..3a070535f83f 100644 --- a/examples/misc/logos2.py +++ b/examples/misc/logos2.py @@ -6,11 +6,12 @@ This example generates the current matplotlib logo. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np + import matplotlib.cm as cm import matplotlib.font_manager -from matplotlib.patches import Rectangle, PathPatch +from matplotlib.patches import PathPatch, Rectangle from matplotlib.text import TextPath import matplotlib.transforms as mtrans diff --git a/examples/misc/multipage_pdf.py b/examples/misc/multipage_pdf.py index dd237fcc36b0..4e0ef9939be0 100644 --- a/examples/misc/multipage_pdf.py +++ b/examples/misc/multipage_pdf.py @@ -12,9 +12,11 @@ """ import datetime + +import matplotlib.pyplot as plt import numpy as np + from matplotlib.backends.backend_pdf import PdfPages -import matplotlib.pyplot as plt # Create the PdfPages object to which we will save the pages: # The with statement makes sure that the PdfPages object is closed properly at diff --git a/examples/misc/packed_bubbles.py b/examples/misc/packed_bubbles.py index 12f51e9569cb..61cb903313a5 100644 --- a/examples/misc/packed_bubbles.py +++ b/examples/misc/packed_bubbles.py @@ -11,8 +11,8 @@ (source: https://gs.statcounter.com/browser-market-share/desktop/worldwidev) """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np browser_market_share = { 'browsers': ['firefox', 'chrome', 'safari', 'edge', 'ie', 'opera'], diff --git a/examples/misc/patheffect_demo.py b/examples/misc/patheffect_demo.py index b5f59ce106fd..39769dc1db8f 100644 --- a/examples/misc/patheffect_demo.py +++ b/examples/misc/patheffect_demo.py @@ -5,9 +5,10 @@ """ import matplotlib.pyplot as plt -from matplotlib import patheffects import numpy as np +from matplotlib import patheffects + fig, (ax1, ax2, ax3) = plt.subplots(1, 3, figsize=(8, 3)) ax1.imshow([[1, 2], [2, 3]]) txt = ax1.annotate("test", (1., 1.), (0., 0), diff --git a/examples/misc/print_stdout_sgskip.py b/examples/misc/print_stdout_sgskip.py index 69b0b33616d8..4a8b63f6d03e 100644 --- a/examples/misc/print_stdout_sgskip.py +++ b/examples/misc/print_stdout_sgskip.py @@ -10,7 +10,9 @@ """ import sys + import matplotlib + matplotlib.use('Agg') import matplotlib.pyplot as plt diff --git a/examples/misc/rasterization_demo.py b/examples/misc/rasterization_demo.py index a00b9c1341e5..db797cb79a62 100644 --- a/examples/misc/rasterization_demo.py +++ b/examples/misc/rasterization_demo.py @@ -34,8 +34,8 @@ """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np d = np.arange(100).reshape(10, 10) # the values to be color-mapped x, y = np.meshgrid(np.arange(11), np.arange(11)) diff --git a/examples/misc/set_and_get.py b/examples/misc/set_and_get.py index 8d217cf94660..453f32276cb1 100644 --- a/examples/misc/set_and_get.py +++ b/examples/misc/set_and_get.py @@ -72,7 +72,6 @@ import matplotlib.pyplot as plt import numpy as np - x = np.arange(0, 1.0, 0.01) y1 = np.sin(2*np.pi*x) y2 = np.sin(4*np.pi*x) diff --git a/examples/misc/svg_filter_line.py b/examples/misc/svg_filter_line.py index da67250890df..5cc4af5d7a66 100644 --- a/examples/misc/svg_filter_line.py +++ b/examples/misc/svg_filter_line.py @@ -13,6 +13,7 @@ import xml.etree.ElementTree as ET import matplotlib.pyplot as plt + import matplotlib.transforms as mtransforms fig1 = plt.figure() diff --git a/examples/misc/svg_filter_pie.py b/examples/misc/svg_filter_pie.py index c5feee824db8..052cde48a245 100644 --- a/examples/misc/svg_filter_pie.py +++ b/examples/misc/svg_filter_pie.py @@ -14,6 +14,7 @@ import xml.etree.ElementTree as ET import matplotlib.pyplot as plt + from matplotlib.patches import Shadow # make a square figure and axes diff --git a/examples/misc/table_demo.py b/examples/misc/table_demo.py index 8afc4c391841..71fb98343d3f 100644 --- a/examples/misc/table_demo.py +++ b/examples/misc/table_demo.py @@ -5,9 +5,8 @@ Demo of table function to display a table within a plot. """ -import numpy as np import matplotlib.pyplot as plt - +import numpy as np data = [[ 66386, 174296, 75131, 577908, 32015], [ 58230, 381139, 78045, 99308, 160454], diff --git a/examples/misc/tickedstroke_demo.py b/examples/misc/tickedstroke_demo.py index 70933d4a45a6..2cdc4593e3b0 100644 --- a/examples/misc/tickedstroke_demo.py +++ b/examples/misc/tickedstroke_demo.py @@ -20,13 +20,14 @@ `. """ +import matplotlib.pyplot as plt +import numpy as np + # %% # Applying TickedStroke to paths # ============================== import matplotlib.patches as patches from matplotlib.path import Path -import numpy as np -import matplotlib.pyplot as plt import matplotlib.patheffects as patheffects fig, ax = plt.subplots(figsize=(6, 6)) diff --git a/examples/misc/transoffset.py b/examples/misc/transoffset.py index 4b1929eb65d9..5254974b46e6 100644 --- a/examples/misc/transoffset.py +++ b/examples/misc/transoffset.py @@ -19,9 +19,9 @@ """ import matplotlib.pyplot as plt -import matplotlib.transforms as mtransforms import numpy as np +import matplotlib.transforms as mtransforms xs = np.arange(7) ys = xs**2 diff --git a/examples/mplot3d/2dcollections3d.py b/examples/mplot3d/2dcollections3d.py index 96183ddb9912..a0155ebb0773 100644 --- a/examples/mplot3d/2dcollections3d.py +++ b/examples/mplot3d/2dcollections3d.py @@ -7,8 +7,8 @@ selective axes of a 3D plot. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np ax = plt.figure().add_subplot(projection='3d') diff --git a/examples/mplot3d/3d_bars.py b/examples/mplot3d/3d_bars.py index fa3798d83b81..609adb8df380 100644 --- a/examples/mplot3d/3d_bars.py +++ b/examples/mplot3d/3d_bars.py @@ -6,9 +6,8 @@ A basic demo of how to plot 3D bars with and without shading. """ -import numpy as np import matplotlib.pyplot as plt - +import numpy as np # set up the figure and axes fig = plt.figure(figsize=(8, 3)) diff --git a/examples/mplot3d/contour3d.py b/examples/mplot3d/contour3d.py index 7b96980e3a73..fb2e5bb5a30d 100644 --- a/examples/mplot3d/contour3d.py +++ b/examples/mplot3d/contour3d.py @@ -7,9 +7,10 @@ plotted on the plane ``z=c``. """ -from mpl_toolkits.mplot3d import axes3d import matplotlib.pyplot as plt + from matplotlib import cm +from mpl_toolkits.mplot3d import axes3d ax = plt.figure().add_subplot(projection='3d') X, Y, Z = axes3d.get_test_data(0.05) diff --git a/examples/mplot3d/contour3d_2.py b/examples/mplot3d/contour3d_2.py index 6dbc62eb9427..1283deb27c81 100644 --- a/examples/mplot3d/contour3d_2.py +++ b/examples/mplot3d/contour3d_2.py @@ -7,9 +7,10 @@ extend the curves vertically into 'ribbons'. """ -from mpl_toolkits.mplot3d import axes3d import matplotlib.pyplot as plt + from matplotlib import cm +from mpl_toolkits.mplot3d import axes3d ax = plt.figure().add_subplot(projection='3d') X, Y, Z = axes3d.get_test_data(0.05) diff --git a/examples/mplot3d/contour3d_3.py b/examples/mplot3d/contour3d_3.py index c6a599328697..6f73fea85dcb 100644 --- a/examples/mplot3d/contour3d_3.py +++ b/examples/mplot3d/contour3d_3.py @@ -7,9 +7,10 @@ See :doc:`contourf3d_2` for the filled version. """ -from mpl_toolkits.mplot3d import axes3d import matplotlib.pyplot as plt +from mpl_toolkits.mplot3d import axes3d + ax = plt.figure().add_subplot(projection='3d') X, Y, Z = axes3d.get_test_data(0.05) diff --git a/examples/mplot3d/contourf3d.py b/examples/mplot3d/contourf3d.py index 6f0261ad0908..9f7157eab82a 100644 --- a/examples/mplot3d/contourf3d.py +++ b/examples/mplot3d/contourf3d.py @@ -10,9 +10,10 @@ corresponding to the level c is graphed on the plane ``z=c``. """ -from mpl_toolkits.mplot3d import axes3d import matplotlib.pyplot as plt + from matplotlib import cm +from mpl_toolkits.mplot3d import axes3d ax = plt.figure().add_subplot(projection='3d') X, Y, Z = axes3d.get_test_data(0.05) diff --git a/examples/mplot3d/contourf3d_2.py b/examples/mplot3d/contourf3d_2.py index d0cb6d4ab79c..1530aee5e87f 100644 --- a/examples/mplot3d/contourf3d_2.py +++ b/examples/mplot3d/contourf3d_2.py @@ -7,9 +7,10 @@ See :doc:`contour3d_3` for the unfilled version. """ -from mpl_toolkits.mplot3d import axes3d import matplotlib.pyplot as plt +from mpl_toolkits.mplot3d import axes3d + ax = plt.figure().add_subplot(projection='3d') X, Y, Z = axes3d.get_test_data(0.05) diff --git a/examples/mplot3d/custom_shaded_3d_surface.py b/examples/mplot3d/custom_shaded_3d_surface.py index 52994aa69e2d..ad34f82cc03f 100644 --- a/examples/mplot3d/custom_shaded_3d_surface.py +++ b/examples/mplot3d/custom_shaded_3d_surface.py @@ -6,12 +6,12 @@ Demonstrates using custom hillshading in a 3D surface plot. """ -from matplotlib import cbook -from matplotlib import cm -from matplotlib.colors import LightSource import matplotlib.pyplot as plt import numpy as np +from matplotlib import cbook, cm +from matplotlib.colors import LightSource + # Load and format data dem = cbook.get_sample_data('jacksboro_fault_dem.npz', np_load=True) z = dem['elevation'] diff --git a/examples/mplot3d/lines3d.py b/examples/mplot3d/lines3d.py index c974bcbdff8d..2fe3b8f30177 100644 --- a/examples/mplot3d/lines3d.py +++ b/examples/mplot3d/lines3d.py @@ -6,9 +6,8 @@ This example demonstrates plotting a parametric curve in 3D. """ -import numpy as np import matplotlib.pyplot as plt - +import numpy as np ax = plt.figure().add_subplot(projection='3d') diff --git a/examples/mplot3d/lorenz_attractor.py b/examples/mplot3d/lorenz_attractor.py index 97300119aeea..0ac54a7adb9b 100644 --- a/examples/mplot3d/lorenz_attractor.py +++ b/examples/mplot3d/lorenz_attractor.py @@ -14,8 +14,8 @@ SciPy's ODE solver, but this approach depends only upon NumPy. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np def lorenz(xyz, *, s=10, r=28, b=2.667): diff --git a/examples/mplot3d/offset.py b/examples/mplot3d/offset.py index db5e6c1f1842..78da5c6b51c3 100644 --- a/examples/mplot3d/offset.py +++ b/examples/mplot3d/offset.py @@ -16,7 +16,6 @@ import matplotlib.pyplot as plt import numpy as np - ax = plt.figure().add_subplot(projection='3d') X, Y = np.mgrid[0:6*np.pi:0.25, 0:4*np.pi:0.25] diff --git a/examples/mplot3d/pathpatch3d.py b/examples/mplot3d/pathpatch3d.py index eff84b1eaf91..f195e19e17a9 100644 --- a/examples/mplot3d/pathpatch3d.py +++ b/examples/mplot3d/pathpatch3d.py @@ -6,8 +6,9 @@ Demonstrate using `.pathpatch_2d_to_3d` to 'draw' shapes and text on a 3D plot. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np + from matplotlib.patches import Circle, PathPatch from matplotlib.text import TextPath from matplotlib.transforms import Affine2D diff --git a/examples/mplot3d/polys3d.py b/examples/mplot3d/polys3d.py index 393f5dcf6544..b174f804d61d 100644 --- a/examples/mplot3d/polys3d.py +++ b/examples/mplot3d/polys3d.py @@ -8,11 +8,13 @@ of 'jagged stained glass' effect. """ -from matplotlib.collections import PolyCollection -import matplotlib.pyplot as plt import math + +import matplotlib.pyplot as plt import numpy as np +from matplotlib.collections import PolyCollection + # Fixing random state for reproducibility np.random.seed(19680801) diff --git a/examples/mplot3d/projections.py b/examples/mplot3d/projections.py index 2a1c2c15be15..4fdeb6729687 100644 --- a/examples/mplot3d/projections.py +++ b/examples/mplot3d/projections.py @@ -28,9 +28,9 @@ """ -from mpl_toolkits.mplot3d import axes3d import matplotlib.pyplot as plt +from mpl_toolkits.mplot3d import axes3d fig, axs = plt.subplots(1, 3, subplot_kw={'projection': '3d'}) diff --git a/examples/mplot3d/rotate_axes3d_sgskip.py b/examples/mplot3d/rotate_axes3d_sgskip.py index 8967277ea5d7..4474fab97460 100644 --- a/examples/mplot3d/rotate_axes3d_sgskip.py +++ b/examples/mplot3d/rotate_axes3d_sgskip.py @@ -11,9 +11,10 @@ intentionally takes a long time to run) """ -from mpl_toolkits.mplot3d import axes3d import matplotlib.pyplot as plt +from mpl_toolkits.mplot3d import axes3d + fig = plt.figure() ax = fig.add_subplot(projection='3d') diff --git a/examples/mplot3d/subplot3d.py b/examples/mplot3d/subplot3d.py index 782b22164c3d..1dfeeb216f58 100644 --- a/examples/mplot3d/subplot3d.py +++ b/examples/mplot3d/subplot3d.py @@ -7,12 +7,11 @@ """ import matplotlib.pyplot as plt -from matplotlib import cm import numpy as np +from matplotlib import cm from mpl_toolkits.mplot3d.axes3d import get_test_data - # set up a figure twice as wide as it is tall fig = plt.figure(figsize=plt.figaspect(0.5)) diff --git a/examples/mplot3d/surface3d.py b/examples/mplot3d/surface3d.py index 5a4a5cd79dbd..e92e6aabd52c 100644 --- a/examples/mplot3d/surface3d.py +++ b/examples/mplot3d/surface3d.py @@ -11,9 +11,10 @@ """ import matplotlib.pyplot as plt +import numpy as np + from matplotlib import cm from matplotlib.ticker import LinearLocator -import numpy as np fig, ax = plt.subplots(subplot_kw={"projection": "3d"}) diff --git a/examples/mplot3d/surface3d_2.py b/examples/mplot3d/surface3d_2.py index bca9f1ca62e8..37ca667d688a 100644 --- a/examples/mplot3d/surface3d_2.py +++ b/examples/mplot3d/surface3d_2.py @@ -9,7 +9,6 @@ import matplotlib.pyplot as plt import numpy as np - fig = plt.figure() ax = fig.add_subplot(projection='3d') diff --git a/examples/mplot3d/surface3d_3.py b/examples/mplot3d/surface3d_3.py index 13fbf38b84f8..a2aca4ca3059 100644 --- a/examples/mplot3d/surface3d_3.py +++ b/examples/mplot3d/surface3d_3.py @@ -7,9 +7,9 @@ """ import matplotlib.pyplot as plt -from matplotlib.ticker import LinearLocator import numpy as np +from matplotlib.ticker import LinearLocator ax = plt.figure().add_subplot(projection='3d') diff --git a/examples/mplot3d/surface3d_radial.py b/examples/mplot3d/surface3d_radial.py index 185f61a6f9b1..0d27c9b58cbb 100644 --- a/examples/mplot3d/surface3d_radial.py +++ b/examples/mplot3d/surface3d_radial.py @@ -13,7 +13,6 @@ import matplotlib.pyplot as plt import numpy as np - fig = plt.figure() ax = fig.add_subplot(projection='3d') diff --git a/examples/mplot3d/text3d.py b/examples/mplot3d/text3d.py index 922d161a9f89..165ae556c334 100644 --- a/examples/mplot3d/text3d.py +++ b/examples/mplot3d/text3d.py @@ -16,7 +16,6 @@ import matplotlib.pyplot as plt - ax = plt.figure().add_subplot(projection='3d') # Demo 1: zdir diff --git a/examples/mplot3d/tricontour3d.py b/examples/mplot3d/tricontour3d.py index 825e90d4dffa..ec0dcb74bb44 100644 --- a/examples/mplot3d/tricontour3d.py +++ b/examples/mplot3d/tricontour3d.py @@ -10,9 +10,10 @@ """ import matplotlib.pyplot as plt -import matplotlib.tri as tri import numpy as np +import matplotlib.tri as tri + n_angles = 48 n_radii = 8 min_radius = 0.25 diff --git a/examples/mplot3d/tricontourf3d.py b/examples/mplot3d/tricontourf3d.py index f579cb1f7c6f..35709027087a 100644 --- a/examples/mplot3d/tricontourf3d.py +++ b/examples/mplot3d/tricontourf3d.py @@ -10,9 +10,10 @@ """ import matplotlib.pyplot as plt -import matplotlib.tri as tri import numpy as np +import matplotlib.tri as tri + # First create the x, y, z coordinates of the points. n_angles = 48 n_radii = 8 diff --git a/examples/mplot3d/trisurf3d.py b/examples/mplot3d/trisurf3d.py index 978b0e3abc02..2d288908ab69 100644 --- a/examples/mplot3d/trisurf3d.py +++ b/examples/mplot3d/trisurf3d.py @@ -9,7 +9,6 @@ import matplotlib.pyplot as plt import numpy as np - n_radii = 8 n_angles = 36 diff --git a/examples/mplot3d/trisurf3d_2.py b/examples/mplot3d/trisurf3d_2.py index 8ed354d5e5e6..cb53aabbea1d 100644 --- a/examples/mplot3d/trisurf3d_2.py +++ b/examples/mplot3d/trisurf3d_2.py @@ -10,10 +10,10 @@ to plot_trisurf. """ -import numpy as np import matplotlib.pyplot as plt -import matplotlib.tri as mtri +import numpy as np +import matplotlib.tri as mtri fig = plt.figure(figsize=plt.figaspect(0.5)) diff --git a/examples/mplot3d/voxels.py b/examples/mplot3d/voxels.py index 5b74914fa271..7bd9cf45a2b0 100644 --- a/examples/mplot3d/voxels.py +++ b/examples/mplot3d/voxels.py @@ -9,7 +9,6 @@ import matplotlib.pyplot as plt import numpy as np - # prepare some coordinates x, y, z = np.indices((8, 8, 8)) diff --git a/examples/mplot3d/voxels_torus.py b/examples/mplot3d/voxels_torus.py index 10aa9c21d124..98621b60976c 100644 --- a/examples/mplot3d/voxels_torus.py +++ b/examples/mplot3d/voxels_torus.py @@ -7,9 +7,10 @@ """ import matplotlib.pyplot as plt -import matplotlib.colors import numpy as np +import matplotlib.colors + def midpoints(x): sl = () diff --git a/examples/mplot3d/wire3d.py b/examples/mplot3d/wire3d.py index 7fc0274309ff..9849c8bebf56 100644 --- a/examples/mplot3d/wire3d.py +++ b/examples/mplot3d/wire3d.py @@ -6,9 +6,9 @@ A very basic demonstration of a wireframe plot. """ -from mpl_toolkits.mplot3d import axes3d import matplotlib.pyplot as plt +from mpl_toolkits.mplot3d import axes3d fig = plt.figure() ax = fig.add_subplot(projection='3d') diff --git a/examples/mplot3d/wire3d_animation_sgskip.py b/examples/mplot3d/wire3d_animation_sgskip.py index a7d77ce4e0c4..a735f41d94b6 100644 --- a/examples/mplot3d/wire3d_animation_sgskip.py +++ b/examples/mplot3d/wire3d_animation_sgskip.py @@ -9,10 +9,10 @@ intentionally takes a long time to run.) """ -import matplotlib.pyplot as plt -import numpy as np import time +import matplotlib.pyplot as plt +import numpy as np fig = plt.figure() ax = fig.add_subplot(projection='3d') diff --git a/examples/mplot3d/wire3d_zero_stride.py b/examples/mplot3d/wire3d_zero_stride.py index f4c679300820..fe45b6c16fcf 100644 --- a/examples/mplot3d/wire3d_zero_stride.py +++ b/examples/mplot3d/wire3d_zero_stride.py @@ -7,9 +7,9 @@ generated in the corresponding direction. """ -from mpl_toolkits.mplot3d import axes3d import matplotlib.pyplot as plt +from mpl_toolkits.mplot3d import axes3d fig, (ax1, ax2) = plt.subplots( 2, 1, figsize=(8, 12), subplot_kw={'projection': '3d'}) diff --git a/examples/pie_and_polar_charts/bar_of_pie.py b/examples/pie_and_polar_charts/bar_of_pie.py index 4cc66afeca49..f386f11bc9aa 100644 --- a/examples/pie_and_polar_charts/bar_of_pie.py +++ b/examples/pie_and_polar_charts/bar_of_pie.py @@ -11,9 +11,10 @@ """ import matplotlib.pyplot as plt -from matplotlib.patches import ConnectionPatch import numpy as np +from matplotlib.patches import ConnectionPatch + # make figure and assign axis objects fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(9, 5)) fig.subplots_adjust(wspace=0) diff --git a/examples/pie_and_polar_charts/pie_and_donut_labels.py b/examples/pie_and_polar_charts/pie_and_donut_labels.py index 26ec6c2dd236..ae9b805cf005 100644 --- a/examples/pie_and_polar_charts/pie_and_donut_labels.py +++ b/examples/pie_and_polar_charts/pie_and_donut_labels.py @@ -28,8 +28,8 @@ # point of the legend will be at the left central point of the bounding box, # spanning from ``(1, 0)`` to ``(1.5, 1)`` in axes coordinates. -import numpy as np import matplotlib.pyplot as plt +import numpy as np fig, ax = plt.subplots(figsize=(6, 3), subplot_kw=dict(aspect="equal")) diff --git a/examples/pie_and_polar_charts/pie_features.py b/examples/pie_and_polar_charts/pie_features.py index d27ed6a03545..cb6ab51c0eac 100644 --- a/examples/pie_and_polar_charts/pie_features.py +++ b/examples/pie_and_polar_charts/pie_features.py @@ -16,6 +16,7 @@ # labels, pass a list of labels to the *labels* parameter import matplotlib.pyplot as plt + labels = 'Frogs', 'Hogs', 'Dogs', 'Logs' sizes = [15, 30, 45, 10] diff --git a/examples/pie_and_polar_charts/polar_bar.py b/examples/pie_and_polar_charts/polar_bar.py index 4172cb71bb33..750032c8710d 100644 --- a/examples/pie_and_polar_charts/polar_bar.py +++ b/examples/pie_and_polar_charts/polar_bar.py @@ -5,9 +5,8 @@ Demo of bar plot on a polar axis. """ -import numpy as np import matplotlib.pyplot as plt - +import numpy as np # Fixing random state for reproducibility np.random.seed(19680801) diff --git a/examples/pie_and_polar_charts/polar_demo.py b/examples/pie_and_polar_charts/polar_demo.py index 0d807d8edd08..75a7d61f6244 100644 --- a/examples/pie_and_polar_charts/polar_demo.py +++ b/examples/pie_and_polar_charts/polar_demo.py @@ -5,9 +5,8 @@ Demo of a line plot on a polar axis. """ -import numpy as np import matplotlib.pyplot as plt - +import numpy as np r = np.arange(0, 2, 0.01) theta = 2 * np.pi * r diff --git a/examples/pie_and_polar_charts/polar_error_caps.py b/examples/pie_and_polar_charts/polar_error_caps.py index 985749184124..aa950e40613a 100644 --- a/examples/pie_and_polar_charts/polar_error_caps.py +++ b/examples/pie_and_polar_charts/polar_error_caps.py @@ -9,8 +9,8 @@ Radius error bars are straight lines oriented towards center with perpendicular caps. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np theta = np.arange(0, 2 * np.pi, np.pi / 4) r = theta / np.pi / 2 + 0.5 diff --git a/examples/pie_and_polar_charts/polar_scatter.py b/examples/pie_and_polar_charts/polar_scatter.py index 89b1f6592f9d..c36d74966805 100644 --- a/examples/pie_and_polar_charts/polar_scatter.py +++ b/examples/pie_and_polar_charts/polar_scatter.py @@ -6,9 +6,8 @@ Size increases radially in this example and color increases with angle (just to verify the symbols are being scattered correctly). """ -import numpy as np import matplotlib.pyplot as plt - +import numpy as np # Fixing random state for reproducibility np.random.seed(19680801) diff --git a/examples/pyplots/axline.py b/examples/pyplots/axline.py index 4c6a1e53db63..dde94af2fcdf 100644 --- a/examples/pyplots/axline.py +++ b/examples/pyplots/axline.py @@ -11,8 +11,8 @@ `~.axes.Axes.axline` draws infinite straight lines in arbitrary directions. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np t = np.linspace(-10, 10, 100) sig = 1 / (1 + np.exp(-t)) diff --git a/examples/pyplots/pyplot_text.py b/examples/pyplots/pyplot_text.py index 42654cf50191..f327e6014807 100644 --- a/examples/pyplots/pyplot_text.py +++ b/examples/pyplots/pyplot_text.py @@ -13,8 +13,8 @@ .. redirect-from:: /gallery/pyplots/pyplot_mathtext """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np t = np.arange(0.0, 2.0, 0.01) s = np.sin(2*np.pi*t) diff --git a/examples/pyplots/pyplot_three.py b/examples/pyplots/pyplot_three.py index 74d2000fb3b3..b14998cca4c9 100644 --- a/examples/pyplots/pyplot_three.py +++ b/examples/pyplots/pyplot_three.py @@ -6,8 +6,8 @@ Plot three datasets with a single call to `~matplotlib.pyplot.plot`. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np # evenly sampled time at 200ms intervals t = np.arange(0., 5., 0.2) diff --git a/examples/pyplots/pyplot_two_subplots.py b/examples/pyplots/pyplot_two_subplots.py index 1ac39dea479b..2eb0237d5521 100644 --- a/examples/pyplots/pyplot_two_subplots.py +++ b/examples/pyplots/pyplot_two_subplots.py @@ -6,8 +6,8 @@ Create a figure with two subplots using `.pyplot.subplot`. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np def f(t): diff --git a/examples/scales/asinh_demo.py b/examples/scales/asinh_demo.py index 6a57ada6dc9d..f416ff6c03c9 100644 --- a/examples/scales/asinh_demo.py +++ b/examples/scales/asinh_demo.py @@ -40,8 +40,8 @@ See `~.scale.AsinhScale`, `~.scale.SymmetricalLogScale`. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np # Prepare sample values for variations on y=x graph: x = np.linspace(-3, 6, 500) diff --git a/examples/scales/custom_scale.py b/examples/scales/custom_scale.py index bfeb8b99bd98..3a7f34fd22f0 100644 --- a/examples/scales/custom_scale.py +++ b/examples/scales/custom_scale.py @@ -14,6 +14,7 @@ import numpy as np from numpy import ma + from matplotlib import scale as mscale from matplotlib import transforms as mtransforms from matplotlib.ticker import FixedLocator, FuncFormatter diff --git a/examples/scales/log_demo.py b/examples/scales/log_demo.py index 0db3a3e74b2b..debbad258bc6 100644 --- a/examples/scales/log_demo.py +++ b/examples/scales/log_demo.py @@ -6,8 +6,8 @@ Examples of plots with logarithmic axes. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np # Data for plotting t = np.arange(0.01, 20.0, 0.01) diff --git a/examples/scales/logit_demo.py b/examples/scales/logit_demo.py index fc8c0e862487..a21abf5b64fb 100644 --- a/examples/scales/logit_demo.py +++ b/examples/scales/logit_demo.py @@ -8,8 +8,8 @@ import math -import numpy as np import matplotlib.pyplot as plt +import numpy as np xmax = 10 x = np.linspace(-xmax, xmax, 10000) diff --git a/examples/scales/power_norm.py b/examples/scales/power_norm.py index 17a1b1e74cd6..e53e015393b0 100644 --- a/examples/scales/power_norm.py +++ b/examples/scales/power_norm.py @@ -8,10 +8,10 @@ """ import matplotlib.pyplot as plt -import matplotlib.colors as mcolors import numpy as np from numpy.random import multivariate_normal +import matplotlib.colors as mcolors # Fixing random state for reproducibility. np.random.seed(19680801) diff --git a/examples/scales/scales.py b/examples/scales/scales.py index d587c57f005d..b2fd6a3d1eab 100644 --- a/examples/scales/scales.py +++ b/examples/scales/scales.py @@ -9,9 +9,10 @@ supplying forward and inverse functions for the scale transformation. """ -import numpy as np import matplotlib.pyplot as plt -from matplotlib.ticker import NullFormatter, FixedLocator +import numpy as np + +from matplotlib.ticker import FixedLocator, NullFormatter # Fixing random state for reproducibility np.random.seed(19680801) diff --git a/examples/shapes_and_collections/arrow_guide.py b/examples/shapes_and_collections/arrow_guide.py index 89956e0576a9..7ca969b7b190 100644 --- a/examples/shapes_and_collections/arrow_guide.py +++ b/examples/shapes_and_collections/arrow_guide.py @@ -27,8 +27,10 @@ .. redirect-from:: /gallery/text_labels_and_annotations/arrow_simple_demo """ -import matplotlib.patches as mpatches import matplotlib.pyplot as plt + +import matplotlib.patches as mpatches + x_tail = 0.1 y_tail = 0.5 x_head = 0.9 diff --git a/examples/shapes_and_collections/artist_reference.py b/examples/shapes_and_collections/artist_reference.py index cde88db73c03..853cc21d10f1 100644 --- a/examples/shapes_and_collections/artist_reference.py +++ b/examples/shapes_and_collections/artist_reference.py @@ -13,11 +13,12 @@ BSD License """ +import matplotlib.pyplot as plt + import matplotlib as mpl import matplotlib.lines as mlines import matplotlib.patches as mpatches import matplotlib.path as mpath -import matplotlib.pyplot as plt # Prepare the data for the PathPatch below. Path = mpath.Path diff --git a/examples/shapes_and_collections/collections.py b/examples/shapes_and_collections/collections.py index 518032657d8e..1f60afda1c5f 100644 --- a/examples/shapes_and_collections/collections.py +++ b/examples/shapes_and_collections/collections.py @@ -18,9 +18,10 @@ """ import matplotlib.pyplot as plt -from matplotlib import collections, transforms import numpy as np +from matplotlib import collections, transforms + nverts = 50 npts = 100 diff --git a/examples/shapes_and_collections/compound_path.py b/examples/shapes_and_collections/compound_path.py index 6a68e28bdf83..0afee13cb2fc 100644 --- a/examples/shapes_and_collections/compound_path.py +++ b/examples/shapes_and_collections/compound_path.py @@ -8,10 +8,11 @@ the compound path """ -from matplotlib.path import Path -from matplotlib.patches import PathPatch import matplotlib.pyplot as plt +from matplotlib.patches import PathPatch +from matplotlib.path import Path + vertices = [] codes = [] diff --git a/examples/shapes_and_collections/dolphin.py b/examples/shapes_and_collections/dolphin.py index 4e56b244d674..bf28fdbcc290 100644 --- a/examples/shapes_and_collections/dolphin.py +++ b/examples/shapes_and_collections/dolphin.py @@ -8,12 +8,13 @@ `~matplotlib.transforms` classes. """ -import matplotlib.cm as cm import matplotlib.pyplot as plt +import numpy as np + +import matplotlib.cm as cm from matplotlib.patches import Circle, PathPatch from matplotlib.path import Path from matplotlib.transforms import Affine2D -import numpy as np # Fixing random state for reproducibility np.random.seed(19680801) diff --git a/examples/shapes_and_collections/donut.py b/examples/shapes_and_collections/donut.py index b5fb50ae21d1..464075336279 100644 --- a/examples/shapes_and_collections/donut.py +++ b/examples/shapes_and_collections/donut.py @@ -7,10 +7,11 @@ This example shows the effect of the path's orientations in a compound path. """ +import matplotlib.pyplot as plt import numpy as np -import matplotlib.path as mpath + import matplotlib.patches as mpatches -import matplotlib.pyplot as plt +import matplotlib.path as mpath def wise(v): diff --git a/examples/shapes_and_collections/ellipse_collection.py b/examples/shapes_and_collections/ellipse_collection.py index 4c55ecc44328..7118e5f7abf2 100644 --- a/examples/shapes_and_collections/ellipse_collection.py +++ b/examples/shapes_and_collections/ellipse_collection.py @@ -10,6 +10,7 @@ import matplotlib.pyplot as plt import numpy as np + from matplotlib.collections import EllipseCollection x = np.arange(10) diff --git a/examples/shapes_and_collections/ellipse_demo.py b/examples/shapes_and_collections/ellipse_demo.py index 62cb68df016a..22de6998418d 100644 --- a/examples/shapes_and_collections/ellipse_demo.py +++ b/examples/shapes_and_collections/ellipse_demo.py @@ -9,8 +9,8 @@ """ import matplotlib.pyplot as plt import numpy as np -from matplotlib.patches import Ellipse +from matplotlib.patches import Ellipse # Fixing random state for reproducibility np.random.seed(19680801) diff --git a/examples/shapes_and_collections/fancybox_demo.py b/examples/shapes_and_collections/fancybox_demo.py index d9d71d55a1df..49692c1be5e6 100644 --- a/examples/shapes_and_collections/fancybox_demo.py +++ b/examples/shapes_and_collections/fancybox_demo.py @@ -9,9 +9,10 @@ import inspect import matplotlib.pyplot as plt -import matplotlib.transforms as mtransforms + import matplotlib.patches as mpatch from matplotlib.patches import FancyBboxPatch +import matplotlib.transforms as mtransforms # %% # First we'll show some sample boxes with fancybox. diff --git a/examples/shapes_and_collections/hatch_demo.py b/examples/shapes_and_collections/hatch_demo.py index 0873b2dc77d1..7acb3ca1bba8 100644 --- a/examples/shapes_and_collections/hatch_demo.py +++ b/examples/shapes_and_collections/hatch_demo.py @@ -15,8 +15,9 @@ """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np + from matplotlib.patches import Ellipse, Polygon x = np.arange(1, 5) diff --git a/examples/shapes_and_collections/hatch_style_reference.py b/examples/shapes_and_collections/hatch_style_reference.py index b2ac2c269100..c487f354f51c 100644 --- a/examples/shapes_and_collections/hatch_style_reference.py +++ b/examples/shapes_and_collections/hatch_style_reference.py @@ -14,6 +14,7 @@ """ import matplotlib.pyplot as plt + from matplotlib.patches import Rectangle fig, axs = plt.subplots(2, 5, constrained_layout=True, figsize=(6.4, 3.2)) diff --git a/examples/shapes_and_collections/line_collection.py b/examples/shapes_and_collections/line_collection.py index 57b15f347050..d534913ad2b2 100644 --- a/examples/shapes_and_collections/line_collection.py +++ b/examples/shapes_and_collections/line_collection.py @@ -8,10 +8,9 @@ """ import matplotlib.pyplot as plt -from matplotlib.collections import LineCollection - import numpy as np +from matplotlib.collections import LineCollection x = np.arange(100) # Here are many sets of y to plot vs. x diff --git a/examples/shapes_and_collections/patch_collection.py b/examples/shapes_and_collections/patch_collection.py index 49549f4d1fc4..8ac9c3a7c304 100644 --- a/examples/shapes_and_collections/patch_collection.py +++ b/examples/shapes_and_collections/patch_collection.py @@ -9,10 +9,11 @@ adds each artist separately to its own axes. """ +import matplotlib.pyplot as plt import numpy as np -from matplotlib.patches import Circle, Wedge, Polygon + from matplotlib.collections import PatchCollection -import matplotlib.pyplot as plt +from matplotlib.patches import Circle, Polygon, Wedge # Fixing random state for reproducibility np.random.seed(19680801) diff --git a/examples/shapes_and_collections/path_patch.py b/examples/shapes_and_collections/path_patch.py index 9e0f1874923b..13acd35ea861 100644 --- a/examples/shapes_and_collections/path_patch.py +++ b/examples/shapes_and_collections/path_patch.py @@ -7,10 +7,11 @@ objects through Matplotlib's API. """ -import matplotlib.path as mpath -import matplotlib.patches as mpatches import matplotlib.pyplot as plt +import matplotlib.patches as mpatches +import matplotlib.path as mpath + fig, ax = plt.subplots() Path = mpath.Path diff --git a/examples/shapes_and_collections/quad_bezier.py b/examples/shapes_and_collections/quad_bezier.py index 4cf8f985d2cc..6f91ad85bf8f 100644 --- a/examples/shapes_and_collections/quad_bezier.py +++ b/examples/shapes_and_collections/quad_bezier.py @@ -7,10 +7,11 @@ polycurve path patch. """ -import matplotlib.path as mpath -import matplotlib.patches as mpatches import matplotlib.pyplot as plt +import matplotlib.patches as mpatches +import matplotlib.path as mpath + Path = mpath.Path fig, ax = plt.subplots() diff --git a/examples/shapes_and_collections/scatter.py b/examples/shapes_and_collections/scatter.py index 6b8bef2b48b4..277eade77efd 100644 --- a/examples/shapes_and_collections/scatter.py +++ b/examples/shapes_and_collections/scatter.py @@ -5,8 +5,8 @@ This example showcases a simple scatter plot. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np # Fixing random state for reproducibility np.random.seed(19680801) diff --git a/examples/showcase/anatomy.py b/examples/showcase/anatomy.py index 94e7a8a0a5dc..52a20b66f0c4 100644 --- a/examples/showcase/anatomy.py +++ b/examples/showcase/anatomy.py @@ -7,8 +7,9 @@ """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np + from matplotlib.patches import Circle from matplotlib.patheffects import withStroke from matplotlib.ticker import AutoMinorLocator, MultipleLocator diff --git a/examples/showcase/firefox.py b/examples/showcase/firefox.py index 69025d39eba1..65682ccd7429 100644 --- a/examples/showcase/firefox.py +++ b/examples/showcase/firefox.py @@ -7,10 +7,12 @@ """ import re -import numpy as np + import matplotlib.pyplot as plt -from matplotlib.path import Path +import numpy as np + import matplotlib.patches as patches +from matplotlib.path import Path # From: https://dmitrybaranovskiy.github.io/raphael/icons/#firefox firefox = "M28.4,22.469c0.479-0.964,0.851-1.991,1.095-3.066c0.953-3.661,0.666-6.854,0.666-6.854l-0.327,2.104c0,0-0.469-3.896-1.044-5.353c-0.881-2.231-1.273-2.214-1.274-2.21c0.542,1.379,0.494,2.169,0.483,2.288c-0.01-0.016-0.019-0.032-0.027-0.047c-0.131-0.324-0.797-1.819-2.225-2.878c-2.502-2.481-5.943-4.014-9.745-4.015c-4.056,0-7.705,1.745-10.238,4.525C5.444,6.5,5.183,5.938,5.159,5.317c0,0-0.002,0.002-0.006,0.005c0-0.011-0.003-0.021-0.003-0.031c0,0-1.61,1.247-1.436,4.612c-0.299,0.574-0.56,1.172-0.777,1.791c-0.375,0.817-0.75,2.004-1.059,3.746c0,0,0.133-0.422,0.399-0.988c-0.064,0.482-0.103,0.971-0.116,1.467c-0.09,0.845-0.118,1.865-0.039,3.088c0,0,0.032-0.406,0.136-1.021c0.834,6.854,6.667,12.165,13.743,12.165l0,0c1.86,0,3.636-0.37,5.256-1.036C24.938,27.771,27.116,25.196,28.4,22.469zM16.002,3.356c2.446,0,4.73,0.68,6.68,1.86c-2.274-0.528-3.433-0.261-3.423-0.248c0.013,0.015,3.384,0.589,3.981,1.411c0,0-1.431,0-2.856,0.41c-0.065,0.019,5.242,0.663,6.327,5.966c0,0-0.582-1.213-1.301-1.42c0.473,1.439,0.351,4.17-0.1,5.528c-0.058,0.174-0.118-0.755-1.004-1.155c0.284,2.037-0.018,5.268-1.432,6.158c-0.109,0.07,0.887-3.189,0.201-1.93c-4.093,6.276-8.959,2.539-10.934,1.208c1.585,0.388,3.267,0.108,4.242-0.559c0.982-0.672,1.564-1.162,2.087-1.047c0.522,0.117,0.87-0.407,0.464-0.872c-0.405-0.466-1.392-1.105-2.725-0.757c-0.94,0.247-2.107,1.287-3.886,0.233c-1.518-0.899-1.507-1.63-1.507-2.095c0-0.366,0.257-0.88,0.734-1.028c0.58,0.062,1.044,0.214,1.537,0.466c0.005-0.135,0.006-0.315-0.001-0.519c0.039-0.077,0.015-0.311-0.047-0.596c-0.036-0.287-0.097-0.582-0.19-0.851c0.01-0.002,0.017-0.007,0.021-0.021c0.076-0.344,2.147-1.544,2.299-1.659c0.153-0.114,0.55-0.378,0.506-1.183c-0.015-0.265-0.058-0.294-2.232-0.286c-0.917,0.003-1.425-0.894-1.589-1.245c0.222-1.231,0.863-2.11,1.919-2.704c0.02-0.011,0.015-0.021-0.008-0.027c0.219-0.127-2.524-0.006-3.76,1.604C9.674,8.045,9.219,7.95,8.71,7.95c-0.638,0-1.139,0.07-1.603,0.187c-0.05,0.013-0.122,0.011-0.208-0.001C6.769,8.04,6.575,7.88,6.365,7.672c0.161-0.18,0.324-0.356,0.495-0.526C9.201,4.804,12.43,3.357,16.002,3.356z" # noqa diff --git a/examples/showcase/integral.py b/examples/showcase/integral.py index 731f7b9ecd50..69e58df3e818 100644 --- a/examples/showcase/integral.py +++ b/examples/showcase/integral.py @@ -12,8 +12,9 @@ * Use of axis spines to hide the top and right spines. * Custom tick placement and labels. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np + from matplotlib.patches import Polygon diff --git a/examples/showcase/mandelbrot.py b/examples/showcase/mandelbrot.py index 6806fc38a5cc..1639cda4b29e 100644 --- a/examples/showcase/mandelbrot.py +++ b/examples/showcase/mandelbrot.py @@ -29,9 +29,11 @@ def mandelbrot_set(xmin, xmax, ymin, ymax, xn, yn, maxiter, horizon=2.0): if __name__ == '__main__': import time + + import matplotlib.pyplot as plt + import matplotlib from matplotlib import colors - import matplotlib.pyplot as plt xmin, xmax, xn = -2.25, +0.75, 3000 // 2 ymin, ymax, yn = -1.25, +1.25, 2500 // 2 diff --git a/examples/showcase/stock_prices.py b/examples/showcase/stock_prices.py index 768efdfd1891..acd82ebeebdf 100644 --- a/examples/showcase/stock_prices.py +++ b/examples/showcase/stock_prices.py @@ -16,10 +16,11 @@ .. _dufte: https://github.com/nschloe/dufte """ -import numpy as np -import matplotlib.transforms as mtransforms import matplotlib.pyplot as plt +import numpy as np + from matplotlib.cbook import get_sample_data +import matplotlib.transforms as mtransforms def convertdate(x): diff --git a/examples/specialty_plots/advanced_hillshading.py b/examples/specialty_plots/advanced_hillshading.py index b0e43f7431d4..db39dcdf42ab 100644 --- a/examples/specialty_plots/advanced_hillshading.py +++ b/examples/specialty_plots/advanced_hillshading.py @@ -5,8 +5,9 @@ Demonstrates a few common tricks with shaded plots. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np + from matplotlib.colors import LightSource, Normalize diff --git a/examples/specialty_plots/hinton_demo.py b/examples/specialty_plots/hinton_demo.py index 91b574b611e4..c47b79fb3acb 100644 --- a/examples/specialty_plots/hinton_demo.py +++ b/examples/specialty_plots/hinton_demo.py @@ -10,8 +10,8 @@ Initial idea from David Warde-Farley on the SciPy Cookbook """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np def hinton(matrix, max_weight=None, ax=None): diff --git a/examples/specialty_plots/leftventricle_bullseye.py b/examples/specialty_plots/leftventricle_bullseye.py index bf88b9476775..70327f49c054 100644 --- a/examples/specialty_plots/leftventricle_bullseye.py +++ b/examples/specialty_plots/leftventricle_bullseye.py @@ -11,9 +11,10 @@ See also the :doc:`/gallery/pie_and_polar_charts/nested_pie` example. """ +import matplotlib.pyplot as plt import numpy as np + import matplotlib as mpl -import matplotlib.pyplot as plt def bullseye_plot(ax, data, seg_bold=None, cmap="viridis", norm=None): diff --git a/examples/specialty_plots/mri_demo.py b/examples/specialty_plots/mri_demo.py index dafd631acaa5..1580ee9a733d 100644 --- a/examples/specialty_plots/mri_demo.py +++ b/examples/specialty_plots/mri_demo.py @@ -8,9 +8,9 @@ """ import matplotlib.pyplot as plt -import matplotlib.cbook as cbook import numpy as np +import matplotlib.cbook as cbook # Data are 256x256 16 bit integers. with cbook.get_sample_data('s1045.ima.gz') as dfile: diff --git a/examples/specialty_plots/mri_with_eeg.py b/examples/specialty_plots/mri_with_eeg.py index 911a26bcbff7..c635a71c9909 100644 --- a/examples/specialty_plots/mri_with_eeg.py +++ b/examples/specialty_plots/mri_with_eeg.py @@ -7,11 +7,11 @@ histogram and some EEG traces. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np + import matplotlib.cbook as cbook import matplotlib.cm as cm - from matplotlib.collections import LineCollection from matplotlib.ticker import MultipleLocator diff --git a/examples/specialty_plots/radar_chart.py b/examples/specialty_plots/radar_chart.py index c452bc0b47ce..3d17659d0bdf 100644 --- a/examples/specialty_plots/radar_chart.py +++ b/examples/specialty_plots/radar_chart.py @@ -14,13 +14,13 @@ .. [1] https://en.wikipedia.org/wiki/Radar_chart """ +import matplotlib.pyplot as plt import numpy as np -import matplotlib.pyplot as plt from matplotlib.patches import Circle, RegularPolygon from matplotlib.path import Path -from matplotlib.projections.polar import PolarAxes from matplotlib.projections import register_projection +from matplotlib.projections.polar import PolarAxes from matplotlib.spines import Spine from matplotlib.transforms import Affine2D diff --git a/examples/specialty_plots/sankey_basics.py b/examples/specialty_plots/sankey_basics.py index 308c22dfb435..dd12b9430709 100644 --- a/examples/specialty_plots/sankey_basics.py +++ b/examples/specialty_plots/sankey_basics.py @@ -10,7 +10,6 @@ from matplotlib.sankey import Sankey - # %% # Example 1 -- Mostly defaults # diff --git a/examples/specialty_plots/sankey_links.py b/examples/specialty_plots/sankey_links.py index c6b1b2101fbe..283cde86e3bf 100644 --- a/examples/specialty_plots/sankey_links.py +++ b/examples/specialty_plots/sankey_links.py @@ -7,6 +7,7 @@ """ import matplotlib.pyplot as plt + from matplotlib.sankey import Sankey links_per_side = 6 diff --git a/examples/specialty_plots/skewt.py b/examples/specialty_plots/skewt.py index 13a46fdc306a..e25998a73c04 100644 --- a/examples/specialty_plots/skewt.py +++ b/examples/specialty_plots/skewt.py @@ -16,10 +16,10 @@ from contextlib import ExitStack from matplotlib.axes import Axes -import matplotlib.transforms as transforms import matplotlib.axis as maxis -import matplotlib.spines as mspines from matplotlib.projections import register_projection +import matplotlib.spines as mspines +import matplotlib.transforms as transforms # The sole purpose of this class is to look at the upper, lower, or total @@ -147,11 +147,13 @@ def upper_xlim(self): if __name__ == '__main__': # Now make a simple example using the custom projection. from io import StringIO - from matplotlib.ticker import (MultipleLocator, NullFormatter, - ScalarFormatter) + import matplotlib.pyplot as plt import numpy as np + from matplotlib.ticker import (MultipleLocator, NullFormatter, + ScalarFormatter) + # Some example data. data_txt = ''' 978.0 345 7.8 0.8 diff --git a/examples/specialty_plots/topographic_hillshading.py b/examples/specialty_plots/topographic_hillshading.py index b9a980448b7f..a7a3ff5df228 100644 --- a/examples/specialty_plots/topographic_hillshading.py +++ b/examples/specialty_plots/topographic_hillshading.py @@ -16,12 +16,12 @@ this example demonstrates how to use the *dx* and *dy* keyword arguments to ensure that the *vert_exag* parameter is the true vertical exaggeration. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np + from matplotlib.cbook import get_sample_data from matplotlib.colors import LightSource - dem = get_sample_data('jacksboro_fault_dem.npz', np_load=True) z = dem['elevation'] # -- Optional dx and dy for accurate vertical exaggeration -------------------- diff --git a/examples/spines/centered_spines_with_arrows.py b/examples/spines/centered_spines_with_arrows.py index 31f01f61fc8d..972e7ebd5e4e 100644 --- a/examples/spines/centered_spines_with_arrows.py +++ b/examples/spines/centered_spines_with_arrows.py @@ -11,7 +11,6 @@ import matplotlib.pyplot as plt import numpy as np - fig, ax = plt.subplots() # Move the left and bottom spines to x = 0 and y = 0, respectively. ax.spines[["left", "bottom"]].set_position(("data", 0)) diff --git a/examples/spines/spine_placement_demo.py b/examples/spines/spine_placement_demo.py index e4fc00ecd561..6f36cd33babd 100644 --- a/examples/spines/spine_placement_demo.py +++ b/examples/spines/spine_placement_demo.py @@ -8,9 +8,8 @@ Note: If you want to obtain arrow heads at the ends of the axes, also check out the :doc:`/gallery/spines/centered_spines_with_arrows` example. """ -import numpy as np import matplotlib.pyplot as plt - +import numpy as np # %% diff --git a/examples/spines/spines.py b/examples/spines/spines.py index 0917fc8c107c..ced4e4af32b6 100644 --- a/examples/spines/spines.py +++ b/examples/spines/spines.py @@ -15,9 +15,8 @@ .. redirect-from:: /gallery/spines/spines_bounds """ -import numpy as np import matplotlib.pyplot as plt - +import numpy as np x = np.linspace(0, 2 * np.pi, 100) y = 2 * np.sin(x) diff --git a/examples/spines/spines_dropped.py b/examples/spines/spines_dropped.py index 94487e86d1d3..40dbb4b95003 100644 --- a/examples/spines/spines_dropped.py +++ b/examples/spines/spines_dropped.py @@ -5,8 +5,8 @@ Demo of spines offset from the axes (a.k.a. "dropped spines"). """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np # Fixing random state for reproducibility np.random.seed(19680801) diff --git a/examples/statistics/barchart_demo.py b/examples/statistics/barchart_demo.py index bf73625c4ea0..e9a6591358bf 100644 --- a/examples/statistics/barchart_demo.py +++ b/examples/statistics/barchart_demo.py @@ -16,9 +16,9 @@ """ from collections import namedtuple -import numpy as np -import matplotlib.pyplot as plt +import matplotlib.pyplot as plt +import numpy as np Student = namedtuple('Student', ['name', 'grade', 'gender']) Score = namedtuple('Score', ['value', 'unit', 'percentile']) diff --git a/examples/statistics/boxplot.py b/examples/statistics/boxplot.py index f5499e793b86..419352380c76 100644 --- a/examples/statistics/boxplot.py +++ b/examples/statistics/boxplot.py @@ -15,8 +15,8 @@ """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np # fake data np.random.seed(19680801) diff --git a/examples/statistics/boxplot_demo.py b/examples/statistics/boxplot_demo.py index 5d5e7fdbb42c..eca0e152078e 100644 --- a/examples/statistics/boxplot_demo.py +++ b/examples/statistics/boxplot_demo.py @@ -14,8 +14,8 @@ import matplotlib.pyplot as plt import numpy as np -from matplotlib.patches import Polygon +from matplotlib.patches import Polygon # Fixing random state for reproducibility np.random.seed(19680801) diff --git a/examples/statistics/bxp.py b/examples/statistics/bxp.py index 7dc4c99649e7..d78747523325 100644 --- a/examples/statistics/bxp.py +++ b/examples/statistics/bxp.py @@ -14,8 +14,9 @@ here: http://vita.had.co.nz/papers/boxplots.pdf """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np + import matplotlib.cbook as cbook # fake data diff --git a/examples/statistics/confidence_ellipse.py b/examples/statistics/confidence_ellipse.py index 512154c67672..2a0427127773 100644 --- a/examples/statistics/confidence_ellipse.py +++ b/examples/statistics/confidence_ellipse.py @@ -17,12 +17,12 @@ """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np + from matplotlib.patches import Ellipse import matplotlib.transforms as transforms - # %% # # The plotting function itself diff --git a/examples/statistics/errorbar.py b/examples/statistics/errorbar.py index 0498734eb480..a25cadf88211 100644 --- a/examples/statistics/errorbar.py +++ b/examples/statistics/errorbar.py @@ -8,8 +8,8 @@ in both the x- and y-directions. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np # example data x = np.arange(0.1, 4, 0.5) diff --git a/examples/statistics/errorbar_features.py b/examples/statistics/errorbar_features.py index d15a045cbf67..349cc89ff2e0 100644 --- a/examples/statistics/errorbar_features.py +++ b/examples/statistics/errorbar_features.py @@ -21,8 +21,8 @@ scale with error bars. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np # example data x = np.arange(0.1, 4, 0.5) diff --git a/examples/statistics/errorbar_limits.py b/examples/statistics/errorbar_limits.py index 1d92c40c0d17..d5b0e476d894 100644 --- a/examples/statistics/errorbar_limits.py +++ b/examples/statistics/errorbar_limits.py @@ -16,8 +16,8 @@ will extend from the data towards decreasing y-values. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np # example data x = np.array([0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0]) diff --git a/examples/statistics/errorbars_and_boxes.py b/examples/statistics/errorbars_and_boxes.py index d253665796dd..f182df6589f2 100644 --- a/examples/statistics/errorbars_and_boxes.py +++ b/examples/statistics/errorbars_and_boxes.py @@ -21,8 +21,9 @@ modified in this example). """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np + from matplotlib.collections import PatchCollection from matplotlib.patches import Rectangle diff --git a/examples/statistics/hexbin_demo.py b/examples/statistics/hexbin_demo.py index 9c26249f02c5..4bd0e0401424 100644 --- a/examples/statistics/hexbin_demo.py +++ b/examples/statistics/hexbin_demo.py @@ -7,8 +7,8 @@ the color represents the number of data points within each bin. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np # Fixing random state for reproducibility np.random.seed(19680801) diff --git a/examples/statistics/hist.py b/examples/statistics/hist.py index 7e8ff37e234c..9e1a308153ef 100644 --- a/examples/statistics/hist.py +++ b/examples/statistics/hist.py @@ -8,6 +8,7 @@ import matplotlib.pyplot as plt import numpy as np + from matplotlib import colors from matplotlib.ticker import PercentFormatter diff --git a/examples/statistics/histogram_cumulative.py b/examples/statistics/histogram_cumulative.py index 67e3d15a8683..a24f378831a4 100644 --- a/examples/statistics/histogram_cumulative.py +++ b/examples/statistics/histogram_cumulative.py @@ -33,8 +33,8 @@ """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np np.random.seed(19680801) diff --git a/examples/statistics/histogram_features.py b/examples/statistics/histogram_features.py index 972ee1621418..354ef1a3b55e 100644 --- a/examples/statistics/histogram_features.py +++ b/examples/statistics/histogram_features.py @@ -17,8 +17,8 @@ .. _section: http://docs.astropy.org/en/stable/visualization/histogram.html """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np np.random.seed(19680801) diff --git a/examples/statistics/histogram_histtypes.py b/examples/statistics/histogram_histtypes.py index f6088cc72347..0188d7bf5d0f 100644 --- a/examples/statistics/histogram_histtypes.py +++ b/examples/statistics/histogram_histtypes.py @@ -14,8 +14,8 @@ http://docs.astropy.org/en/stable/visualization/histogram.html """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np np.random.seed(19680801) diff --git a/examples/statistics/histogram_multihist.py b/examples/statistics/histogram_multihist.py index 63fc651b8813..f1957dc38939 100644 --- a/examples/statistics/histogram_multihist.py +++ b/examples/statistics/histogram_multihist.py @@ -16,8 +16,8 @@ http://docs.astropy.org/en/stable/visualization/histogram.html """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np np.random.seed(19680801) diff --git a/examples/statistics/multiple_histograms_side_by_side.py b/examples/statistics/multiple_histograms_side_by_side.py index 5113222d7c15..3c5766f8e546 100644 --- a/examples/statistics/multiple_histograms_side_by_side.py +++ b/examples/statistics/multiple_histograms_side_by_side.py @@ -21,8 +21,8 @@ http://docs.astropy.org/en/stable/visualization/histogram.html """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np np.random.seed(19680801) number_of_bins = 20 diff --git a/examples/statistics/time_series_histogram.py b/examples/statistics/time_series_histogram.py index 24b268d6d126..47b81d4df7be 100644 --- a/examples/statistics/time_series_histogram.py +++ b/examples/statistics/time_series_histogram.py @@ -26,9 +26,10 @@ from copy import copy import time +import matplotlib.pyplot as plt import numpy as np import numpy.matlib -import matplotlib.pyplot as plt + from matplotlib.colors import LogNorm fig, axes = plt.subplots(nrows=3, figsize=(6, 8), constrained_layout=True) diff --git a/examples/statistics/violinplot.py b/examples/statistics/violinplot.py index 799757c7fa5a..8779022dd96c 100644 --- a/examples/statistics/violinplot.py +++ b/examples/statistics/violinplot.py @@ -16,8 +16,8 @@ have a great section: https://scikit-learn.org/stable/modules/density.html """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np # Fixing random state for reproducibility np.random.seed(19680801) diff --git a/examples/style_sheets/bmh.py b/examples/style_sheets/bmh.py index c0379b188c2a..941a21a3030f 100644 --- a/examples/style_sheets/bmh.py +++ b/examples/style_sheets/bmh.py @@ -9,9 +9,8 @@ .. [1] http://camdavidsonpilon.github.io/Probabilistic-Programming-and-Bayesian-Methods-for-Hackers/ """ -import numpy as np import matplotlib.pyplot as plt - +import numpy as np # Fixing random state for reproducibility np.random.seed(19680801) diff --git a/examples/style_sheets/dark_background.py b/examples/style_sheets/dark_background.py index 4342667cfbe4..e142521c6460 100644 --- a/examples/style_sheets/dark_background.py +++ b/examples/style_sheets/dark_background.py @@ -8,9 +8,8 @@ elements default to colors defined by an rc parameter. """ -import numpy as np import matplotlib.pyplot as plt - +import numpy as np plt.style.use('dark_background') diff --git a/examples/style_sheets/fivethirtyeight.py b/examples/style_sheets/fivethirtyeight.py index 64b7ab07b6a6..45dd851e81d6 100644 --- a/examples/style_sheets/fivethirtyeight.py +++ b/examples/style_sheets/fivethirtyeight.py @@ -10,7 +10,6 @@ import matplotlib.pyplot as plt import numpy as np - plt.style.use('fivethirtyeight') x = np.linspace(0, 10) diff --git a/examples/style_sheets/ggplot.py b/examples/style_sheets/ggplot.py index 52139c348b82..51a103f5f970 100644 --- a/examples/style_sheets/ggplot.py +++ b/examples/style_sheets/ggplot.py @@ -14,8 +14,8 @@ .. _R: https://www.r-project.org/ """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np plt.style.use('ggplot') diff --git a/examples/style_sheets/grayscale.py b/examples/style_sheets/grayscale.py index 5203b0f0b72f..e2c3788e94b3 100644 --- a/examples/style_sheets/grayscale.py +++ b/examples/style_sheets/grayscale.py @@ -8,8 +8,8 @@ plot elements respect `.rcParams`. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np # Fixing random state for reproducibility np.random.seed(19680801) diff --git a/examples/style_sheets/plot_solarizedlight2.py b/examples/style_sheets/plot_solarizedlight2.py index 5fa82b295932..c1d37422216a 100644 --- a/examples/style_sheets/plot_solarizedlight2.py +++ b/examples/style_sheets/plot_solarizedlight2.py @@ -24,7 +24,6 @@ import matplotlib.pyplot as plt import numpy as np - # Fixing random state for reproducibility np.random.seed(19680801) diff --git a/examples/style_sheets/style_sheets_reference.py b/examples/style_sheets/style_sheets_reference.py index 90e5812a30b8..9e8a8ee3af96 100644 --- a/examples/style_sheets/style_sheets_reference.py +++ b/examples/style_sheets/style_sheets_reference.py @@ -9,8 +9,9 @@ """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np + import matplotlib.colors as mcolors from matplotlib.patches import Rectangle diff --git a/examples/subplots_axes_and_figures/align_labels_demo.py b/examples/subplots_axes_and_figures/align_labels_demo.py index 0e600b790c47..88f443ca0076 100644 --- a/examples/subplots_axes_and_figures/align_labels_demo.py +++ b/examples/subplots_axes_and_figures/align_labels_demo.py @@ -14,6 +14,7 @@ """ import matplotlib.pyplot as plt import numpy as np + import matplotlib.gridspec as gridspec fig = plt.figure(tight_layout=True) diff --git a/examples/subplots_axes_and_figures/auto_subplots_adjust.py b/examples/subplots_axes_and_figures/auto_subplots_adjust.py index a99c84d18a90..bf809061d59a 100644 --- a/examples/subplots_axes_and_figures/auto_subplots_adjust.py +++ b/examples/subplots_axes_and_figures/auto_subplots_adjust.py @@ -41,6 +41,7 @@ """ import matplotlib.pyplot as plt + import matplotlib.transforms as mtransforms fig, ax = plt.subplots() diff --git a/examples/subplots_axes_and_figures/axes_box_aspect.py b/examples/subplots_axes_and_figures/axes_box_aspect.py index 752d8d9ba64c..12a7c2c4eac8 100644 --- a/examples/subplots_axes_and_figures/axes_box_aspect.py +++ b/examples/subplots_axes_and_figures/axes_box_aspect.py @@ -19,8 +19,8 @@ # # Produce a square axes, no matter what the data limits are. -import numpy as np import matplotlib.pyplot as plt +import numpy as np fig1, ax = plt.subplots() diff --git a/examples/subplots_axes_and_figures/axes_margins.py b/examples/subplots_axes_and_figures/axes_margins.py index 7eb3a461beef..934e5ac6366b 100644 --- a/examples/subplots_axes_and_figures/axes_margins.py +++ b/examples/subplots_axes_and_figures/axes_margins.py @@ -11,8 +11,9 @@ """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np + from matplotlib.patches import Polygon diff --git a/examples/subplots_axes_and_figures/axes_zoom_effect.py b/examples/subplots_axes_and_figures/axes_zoom_effect.py index 4b7ff6e91e30..a8076db48528 100644 --- a/examples/subplots_axes_and_figures/axes_zoom_effect.py +++ b/examples/subplots_axes_and_figures/axes_zoom_effect.py @@ -7,10 +7,11 @@ import matplotlib.pyplot as plt -from matplotlib.transforms import ( - Bbox, TransformedBbox, blended_transform_factory) -from mpl_toolkits.axes_grid1.inset_locator import ( - BboxPatch, BboxConnector, BboxConnectorPatch) +from matplotlib.transforms import (Bbox, TransformedBbox, + blended_transform_factory) +from mpl_toolkits.axes_grid1.inset_locator import (BboxConnector, + BboxConnectorPatch, + BboxPatch) def connect_bbox(bbox1, bbox2, diff --git a/examples/subplots_axes_and_figures/axhspan_demo.py b/examples/subplots_axes_and_figures/axhspan_demo.py index 0cc9b49dd22b..bc1d7bff154b 100644 --- a/examples/subplots_axes_and_figures/axhspan_demo.py +++ b/examples/subplots_axes_and_figures/axhspan_demo.py @@ -7,8 +7,8 @@ vertical direction, and lines than span the axes with an arbitrary orientation. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np t = np.arange(-1, 2, .01) s = np.sin(2 * np.pi * t) diff --git a/examples/subplots_axes_and_figures/broken_axis.py b/examples/subplots_axes_and_figures/broken_axis.py index 38d859d0e00d..343fe5d4865b 100644 --- a/examples/subplots_axes_and_figures/broken_axis.py +++ b/examples/subplots_axes_and_figures/broken_axis.py @@ -6,8 +6,8 @@ Broken axis example, where the y-axis will have a portion cut out. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np np.random.seed(19680801) diff --git a/examples/subplots_axes_and_figures/colorbar_placement.py b/examples/subplots_axes_and_figures/colorbar_placement.py index 1e6aa1ed78c5..0135629b206e 100644 --- a/examples/subplots_axes_and_figures/colorbar_placement.py +++ b/examples/subplots_axes_and_figures/colorbar_placement.py @@ -13,7 +13,6 @@ import matplotlib.pyplot as plt import numpy as np - # Fixing random state for reproducibility np.random.seed(19680801) diff --git a/examples/subplots_axes_and_figures/custom_figure_class.py b/examples/subplots_axes_and_figures/custom_figure_class.py index 49070bcd7c54..96c7f1113787 100644 --- a/examples/subplots_axes_and_figures/custom_figure_class.py +++ b/examples/subplots_axes_and_figures/custom_figure_class.py @@ -14,9 +14,10 @@ """ import matplotlib.pyplot as plt -from matplotlib.figure import Figure import numpy as np +from matplotlib.figure import Figure + class WatermarkFigure(Figure): """A figure with a text watermark.""" diff --git a/examples/subplots_axes_and_figures/demo_tight_layout.py b/examples/subplots_axes_and_figures/demo_tight_layout.py index 8c76e4821355..55b54c327a7b 100644 --- a/examples/subplots_axes_and_figures/demo_tight_layout.py +++ b/examples/subplots_axes_and_figures/demo_tight_layout.py @@ -11,10 +11,10 @@ """ -import matplotlib.pyplot as plt import itertools import warnings +import matplotlib.pyplot as plt fontsizes = itertools.cycle([8, 16, 24, 32]) diff --git a/examples/subplots_axes_and_figures/figure_size_units.py b/examples/subplots_axes_and_figures/figure_size_units.py index 2af10405a569..4b87ff658f97 100644 --- a/examples/subplots_axes_and_figures/figure_size_units.py +++ b/examples/subplots_axes_and_figures/figure_size_units.py @@ -12,6 +12,7 @@ # sphinx_gallery_thumbnail_number = 2 import matplotlib.pyplot as plt + text_kwargs = dict(ha='center', va='center', fontsize=28, color='C1') # %% diff --git a/examples/subplots_axes_and_figures/figure_title.py b/examples/subplots_axes_and_figures/figure_title.py index c3277fa6d8c0..790a522b8d16 100644 --- a/examples/subplots_axes_and_figures/figure_title.py +++ b/examples/subplots_axes_and_figures/figure_title.py @@ -10,11 +10,10 @@ We can also add figure-level x- and y-labels using `.FigureBase.supxlabel` and `.FigureBase.supylabel`. """ -from matplotlib.cbook import get_sample_data import matplotlib.pyplot as plt - import numpy as np +from matplotlib.cbook import get_sample_data x = np.linspace(0.0, 5.0, 501) diff --git a/examples/subplots_axes_and_figures/gridspec_multicolumn.py b/examples/subplots_axes_and_figures/gridspec_multicolumn.py index 5a22aa2d310c..a80d66a2986d 100644 --- a/examples/subplots_axes_and_figures/gridspec_multicolumn.py +++ b/examples/subplots_axes_and_figures/gridspec_multicolumn.py @@ -9,6 +9,7 @@ """ import matplotlib.pyplot as plt + from matplotlib.gridspec import GridSpec diff --git a/examples/subplots_axes_and_figures/gridspec_nested.py b/examples/subplots_axes_and_figures/gridspec_nested.py index 2a73fc4b3c1c..a2750a0ecb49 100644 --- a/examples/subplots_axes_and_figures/gridspec_nested.py +++ b/examples/subplots_axes_and_figures/gridspec_nested.py @@ -12,6 +12,7 @@ """ import matplotlib.pyplot as plt + import matplotlib.gridspec as gridspec diff --git a/examples/subplots_axes_and_figures/secondary_axis.py b/examples/subplots_axes_and_figures/secondary_axis.py index cabe46023a73..ffb932a16484 100644 --- a/examples/subplots_axes_and_figures/secondary_axis.py +++ b/examples/subplots_axes_and_figures/secondary_axis.py @@ -11,9 +11,11 @@ function in a tuple to the *functions* keyword argument: """ +import datetime + import matplotlib.pyplot as plt import numpy as np -import datetime + import matplotlib.dates as mdates from matplotlib.ticker import AutoMinorLocator diff --git a/examples/subplots_axes_and_figures/share_axis_lims_views.py b/examples/subplots_axes_and_figures/share_axis_lims_views.py index 852ee744a939..751f7effc6a1 100644 --- a/examples/subplots_axes_and_figures/share_axis_lims_views.py +++ b/examples/subplots_axes_and_figures/share_axis_lims_views.py @@ -10,8 +10,8 @@ share with. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np t = np.arange(0, 10, 0.01) diff --git a/examples/subplots_axes_and_figures/subplot.py b/examples/subplots_axes_and_figures/subplot.py index 3aeb8af45a97..4b78e7a5a840 100644 --- a/examples/subplots_axes_and_figures/subplot.py +++ b/examples/subplots_axes_and_figures/subplot.py @@ -10,8 +10,8 @@ .. redirect-from:: /gallery/subplots_axes_and_figures/subplot_demo """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np # Create some fake data. x1 = np.linspace(0.0, 5.0) diff --git a/examples/subplots_axes_and_figures/two_scales.py b/examples/subplots_axes_and_figures/two_scales.py index 75660b2d7bcd..857c22d5094d 100644 --- a/examples/subplots_axes_and_figures/two_scales.py +++ b/examples/subplots_axes_and_figures/two_scales.py @@ -13,8 +13,8 @@ `.Axes.twiny` is available to generate axes that share a *y* axis but have different top and bottom scales. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np # Create some mock data t = np.arange(0.01, 10.0, 0.01) diff --git a/examples/subplots_axes_and_figures/zoom_inset_axes.py b/examples/subplots_axes_and_figures/zoom_inset_axes.py index e0939c2029c0..3d577b8e0f79 100644 --- a/examples/subplots_axes_and_figures/zoom_inset_axes.py +++ b/examples/subplots_axes_and_figures/zoom_inset_axes.py @@ -6,10 +6,11 @@ Example of an inset axes and a rectangle showing where the zoom is located. """ -from matplotlib import cbook import matplotlib.pyplot as plt import numpy as np +from matplotlib import cbook + def get_demo_image(): z = cbook.get_sample_data("axes_grid/bivariate_normal.npy", np_load=True) diff --git a/examples/text_labels_and_annotations/align_ylabels.py b/examples/text_labels_and_annotations/align_ylabels.py index c0e08729039f..7e6e4152da7f 100644 --- a/examples/text_labels_and_annotations/align_ylabels.py +++ b/examples/text_labels_and_annotations/align_ylabels.py @@ -8,8 +8,8 @@ .. redirect-from:: /gallery/pyplots/align_ylabels """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np def make_plot(axs): diff --git a/examples/text_labels_and_annotations/angle_annotation.py b/examples/text_labels_and_annotations/angle_annotation.py index 613ffc74e805..97561c6c2f36 100644 --- a/examples/text_labels_and_annotations/angle_annotation.py +++ b/examples/text_labels_and_annotations/angle_annotation.py @@ -57,10 +57,11 @@ # is hence not strictly necessary to keep a reference to it. -import numpy as np import matplotlib.pyplot as plt +import numpy as np + from matplotlib.patches import Arc -from matplotlib.transforms import IdentityTransform, TransformedBbox, Bbox +from matplotlib.transforms import Bbox, IdentityTransform, TransformedBbox class AngleAnnotation(Arc): diff --git a/examples/text_labels_and_annotations/angles_on_bracket_arrows.py b/examples/text_labels_and_annotations/angles_on_bracket_arrows.py index b48e7c9cc34f..bb536cd5d2c3 100644 --- a/examples/text_labels_and_annotations/angles_on_bracket_arrows.py +++ b/examples/text_labels_and_annotations/angles_on_bracket_arrows.py @@ -12,6 +12,7 @@ import matplotlib.pyplot as plt import numpy as np + from matplotlib.patches import FancyArrowPatch diff --git a/examples/text_labels_and_annotations/annotate_transform.py b/examples/text_labels_and_annotations/annotate_transform.py index bfd7027e5a5b..d2bfbcef4df9 100644 --- a/examples/text_labels_and_annotations/annotate_transform.py +++ b/examples/text_labels_and_annotations/annotate_transform.py @@ -10,8 +10,8 @@ .. redirect-from:: /gallery/pyplots/annotate_transform """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np x = np.arange(0, 10, 0.005) y = np.exp(-x/2.) * np.sin(2*np.pi*x) diff --git a/examples/text_labels_and_annotations/annotation_basic.py b/examples/text_labels_and_annotations/annotation_basic.py index f42b5d85c512..2a5b115a96b1 100644 --- a/examples/text_labels_and_annotations/annotation_basic.py +++ b/examples/text_labels_and_annotations/annotation_basic.py @@ -11,8 +11,8 @@ .. redirect-from:: /gallery/pyplots/annotation_basic """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np fig, ax = plt.subplots() diff --git a/examples/text_labels_and_annotations/annotation_demo.py b/examples/text_labels_and_annotations/annotation_demo.py index a37859a1b59e..a17b60d50e0d 100644 --- a/examples/text_labels_and_annotations/annotation_demo.py +++ b/examples/text_labels_and_annotations/annotation_demo.py @@ -11,10 +11,10 @@ """ import matplotlib.pyplot as plt -from matplotlib.patches import Ellipse import numpy as np -from matplotlib.text import OffsetFrom +from matplotlib.patches import Ellipse +from matplotlib.text import OffsetFrom # %% # Specifying text points and annotation points diff --git a/examples/text_labels_and_annotations/annotation_polar.py b/examples/text_labels_and_annotations/annotation_polar.py index 08778fe8ec46..910aaad6757b 100644 --- a/examples/text_labels_and_annotations/annotation_polar.py +++ b/examples/text_labels_and_annotations/annotation_polar.py @@ -10,8 +10,8 @@ .. redirect-from:: /gallery/pyplots/annotation_polar """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np fig = plt.figure() ax = fig.add_subplot(projection='polar') diff --git a/examples/text_labels_and_annotations/custom_legends.py b/examples/text_labels_and_annotations/custom_legends.py index ecb61e200d3d..62965a455d61 100644 --- a/examples/text_labels_and_annotations/custom_legends.py +++ b/examples/text_labels_and_annotations/custom_legends.py @@ -18,11 +18,12 @@ want a legend item to show up for each one. If you simply plot the lines and call ``ax.legend()``, you will get the following: """ +import matplotlib.pyplot as plt +import numpy as np + # sphinx_gallery_thumbnail_number = 2 import matplotlib as mpl from matplotlib import cycler -import matplotlib.pyplot as plt -import numpy as np # Fixing random state for reproducibility np.random.seed(19680801) @@ -42,6 +43,7 @@ # explicitly tied to the data that was plotted. For example: from matplotlib.lines import Line2D + custom_lines = [Line2D([0], [0], color=cmap(0.), lw=4), Line2D([0], [0], color=cmap(.5), lw=4), Line2D([0], [0], color=cmap(1.), lw=4)] @@ -55,8 +57,8 @@ # There are many other Matplotlib objects that can be used in this way. In the # code below we've listed a few common ones. -from matplotlib.patches import Patch from matplotlib.lines import Line2D +from matplotlib.patches import Patch legend_elements = [Line2D([0], [0], color='b', lw=4, label='Line'), Line2D([0], [0], marker='o', color='w', label='Scatter', diff --git a/examples/text_labels_and_annotations/date.py b/examples/text_labels_and_annotations/date.py index 9c72972a04e4..12a7f7f60f33 100644 --- a/examples/text_labels_and_annotations/date.py +++ b/examples/text_labels_and_annotations/date.py @@ -23,8 +23,9 @@ """ import matplotlib.pyplot as plt -import matplotlib.dates as mdates + import matplotlib.cbook as cbook +import matplotlib.dates as mdates # Load a numpy record array from yahoo csv data with fields date, open, high, # low, close, volume, adj_close from the mpl-data/sample_data directory. The diff --git a/examples/text_labels_and_annotations/demo_annotation_box.py b/examples/text_labels_and_annotations/demo_annotation_box.py index 52a1c854c4cb..ad28c4abd96c 100644 --- a/examples/text_labels_and_annotations/demo_annotation_box.py +++ b/examples/text_labels_and_annotations/demo_annotation_box.py @@ -12,11 +12,10 @@ import matplotlib.pyplot as plt import numpy as np -from matplotlib.patches import Circle -from matplotlib.offsetbox import (TextArea, DrawingArea, OffsetImage, - AnnotationBbox) from matplotlib.cbook import get_sample_data - +from matplotlib.offsetbox import (AnnotationBbox, DrawingArea, OffsetImage, + TextArea) +from matplotlib.patches import Circle fig, ax = plt.subplots() diff --git a/examples/text_labels_and_annotations/demo_text_path.py b/examples/text_labels_and_annotations/demo_text_path.py index 1899f314f5b6..249fad888527 100644 --- a/examples/text_labels_and_annotations/demo_text_path.py +++ b/examples/text_labels_and_annotations/demo_text_path.py @@ -9,14 +9,15 @@ """ import matplotlib.pyplot as plt +import numpy as np + from matplotlib.cbook import get_sample_data from matplotlib.image import BboxImage -from matplotlib.offsetbox import ( - AnnotationBbox, AnchoredOffsetbox, AuxTransformBox) +from matplotlib.offsetbox import (AnchoredOffsetbox, AnnotationBbox, + AuxTransformBox) from matplotlib.patches import PathPatch, Shadow from matplotlib.text import TextPath from matplotlib.transforms import IdentityTransform -import numpy as np class PathClippedImagePatch(PathPatch): diff --git a/examples/text_labels_and_annotations/fancyarrow_demo.py b/examples/text_labels_and_annotations/fancyarrow_demo.py index 85df80c700cf..8d0027831e4a 100644 --- a/examples/text_labels_and_annotations/fancyarrow_demo.py +++ b/examples/text_labels_and_annotations/fancyarrow_demo.py @@ -7,12 +7,13 @@ """ import inspect -import re import itertools +import re -import matplotlib.patches as mpatches import matplotlib.pyplot as plt +import matplotlib.patches as mpatches + styles = mpatches.ArrowStyle.get_styles() ncol = 2 nrow = (len(styles) + 1) // ncol diff --git a/examples/text_labels_and_annotations/figlegend_demo.py b/examples/text_labels_and_annotations/figlegend_demo.py index 7f4e59d573db..4659cc47ccf1 100644 --- a/examples/text_labels_and_annotations/figlegend_demo.py +++ b/examples/text_labels_and_annotations/figlegend_demo.py @@ -7,8 +7,8 @@ the sub-axes of a figure can be plotted instead. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np fig, axs = plt.subplots(1, 2) diff --git a/examples/text_labels_and_annotations/font_file.py b/examples/text_labels_and_annotations/font_file.py index 575affa9b011..8242b57839aa 100644 --- a/examples/text_labels_and_annotations/font_file.py +++ b/examples/text_labels_and_annotations/font_file.py @@ -18,9 +18,10 @@ from pathlib import Path -import matplotlib as mpl import matplotlib.pyplot as plt +import matplotlib as mpl + fig, ax = plt.subplots() fpath = Path(mpl.get_data_path(), "fonts/ttf/cmr10.ttf") diff --git a/examples/text_labels_and_annotations/font_table.py b/examples/text_labels_and_annotations/font_table.py index 6b03a602fbe6..490f627b1033 100644 --- a/examples/text_labels_and_annotations/font_table.py +++ b/examples/text_labels_and_annotations/font_table.py @@ -18,9 +18,10 @@ from pathlib import Path import unicodedata +import matplotlib.pyplot as plt + import matplotlib.font_manager as fm from matplotlib.ft2font import FT2Font -import matplotlib.pyplot as plt def print_glyphs(path): diff --git a/examples/text_labels_and_annotations/fonts_demo.py b/examples/text_labels_and_annotations/fonts_demo.py index 112c6b0b4ce9..bc36c10bce8b 100644 --- a/examples/text_labels_and_annotations/fonts_demo.py +++ b/examples/text_labels_and_annotations/fonts_demo.py @@ -8,9 +8,10 @@ See :doc:`fonts_demo_kw` to achieve the same effect using keyword arguments. """ -from matplotlib.font_manager import FontProperties import matplotlib.pyplot as plt +from matplotlib.font_manager import FontProperties + fig = plt.figure() alignment = {'horizontalalignment': 'center', 'verticalalignment': 'baseline'} yp = [0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2] diff --git a/examples/text_labels_and_annotations/label_subplots.py b/examples/text_labels_and_annotations/label_subplots.py index 2cd7ba684752..16bb3f9f8d14 100644 --- a/examples/text_labels_and_annotations/label_subplots.py +++ b/examples/text_labels_and_annotations/label_subplots.py @@ -14,6 +14,7 @@ """ import matplotlib.pyplot as plt + import matplotlib.transforms as mtransforms fig, axs = plt.subplot_mosaic([['a)', 'c)'], ['b)', 'c)'], ['d)', 'd)']], diff --git a/examples/text_labels_and_annotations/legend.py b/examples/text_labels_and_annotations/legend.py index d0df56d3a205..3113b4c5aad9 100644 --- a/examples/text_labels_and_annotations/legend.py +++ b/examples/text_labels_and_annotations/legend.py @@ -7,8 +7,8 @@ """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np # Make some fake data. a = b = np.arange(0, 3, .02) diff --git a/examples/text_labels_and_annotations/legend_demo.py b/examples/text_labels_and_annotations/legend_demo.py index 8c87d09dc157..99da1327832a 100644 --- a/examples/text_labels_and_annotations/legend_demo.py +++ b/examples/text_labels_and_annotations/legend_demo.py @@ -12,10 +12,11 @@ """ import matplotlib.pyplot as plt +import numpy as np + import matplotlib.collections as mcol from matplotlib.legend_handler import HandlerLineCollection, HandlerTuple from matplotlib.lines import Line2D -import numpy as np t1 = np.arange(0.0, 2.0, 0.1) t2 = np.arange(0.0, 2.0, 0.01) diff --git a/examples/text_labels_and_annotations/line_with_text.py b/examples/text_labels_and_annotations/line_with_text.py index 12cd5e77ff0d..8a62733b13ce 100644 --- a/examples/text_labels_and_annotations/line_with_text.py +++ b/examples/text_labels_and_annotations/line_with_text.py @@ -6,11 +6,12 @@ Override basic methods so an artist can contain another artist. In this case, the line contains a Text instance to label it. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np + import matplotlib.lines as lines -import matplotlib.transforms as mtransforms import matplotlib.text as mtext +import matplotlib.transforms as mtransforms class MyLine(lines.Line2D): diff --git a/examples/text_labels_and_annotations/mathtext_asarray.py b/examples/text_labels_and_annotations/mathtext_asarray.py index a90421b86760..3c8a763451ea 100644 --- a/examples/text_labels_and_annotations/mathtext_asarray.py +++ b/examples/text_labels_and_annotations/mathtext_asarray.py @@ -6,8 +6,9 @@ from io import BytesIO -from matplotlib.figure import Figure import matplotlib.pyplot as plt + +from matplotlib.figure import Figure from matplotlib.transforms import IdentityTransform diff --git a/examples/text_labels_and_annotations/mathtext_examples.py b/examples/text_labels_and_annotations/mathtext_examples.py index 838b68bb2ca2..0cdae3c8193c 100644 --- a/examples/text_labels_and_annotations/mathtext_examples.py +++ b/examples/text_labels_and_annotations/mathtext_examples.py @@ -11,7 +11,6 @@ import matplotlib.pyplot as plt - # Selection of features following "Writing mathematical expressions" tutorial, # with randomly picked examples. mathtext_demos = { diff --git a/examples/text_labels_and_annotations/mathtext_fontfamily_example.py b/examples/text_labels_and_annotations/mathtext_fontfamily_example.py index 77095b00dee8..3dd480a5fa14 100644 --- a/examples/text_labels_and_annotations/mathtext_fontfamily_example.py +++ b/examples/text_labels_and_annotations/mathtext_fontfamily_example.py @@ -13,7 +13,6 @@ import matplotlib.pyplot as plt - fig, ax = plt.subplots(figsize=(6, 5)) # A simple plot for the background. diff --git a/examples/text_labels_and_annotations/placing_text_boxes.py b/examples/text_labels_and_annotations/placing_text_boxes.py index bb8021706c1b..c90921df9cba 100644 --- a/examples/text_labels_and_annotations/placing_text_boxes.py +++ b/examples/text_labels_and_annotations/placing_text_boxes.py @@ -10,8 +10,8 @@ dictionary with keys that are Patch properties. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np np.random.seed(19680801) diff --git a/examples/text_labels_and_annotations/rainbow_text.py b/examples/text_labels_and_annotations/rainbow_text.py index 9cec0bdc8f81..951a4547c537 100644 --- a/examples/text_labels_and_annotations/rainbow_text.py +++ b/examples/text_labels_and_annotations/rainbow_text.py @@ -24,6 +24,7 @@ """ import matplotlib.pyplot as plt + from matplotlib.transforms import Affine2D, offset_copy diff --git a/examples/text_labels_and_annotations/stix_fonts_demo.py b/examples/text_labels_and_annotations/stix_fonts_demo.py index 16872d188e4a..7852b3e0b09f 100644 --- a/examples/text_labels_and_annotations/stix_fonts_demo.py +++ b/examples/text_labels_and_annotations/stix_fonts_demo.py @@ -9,7 +9,6 @@ import matplotlib.pyplot as plt - circle123 = "\N{CIRCLED DIGIT ONE}\N{CIRCLED DIGIT TWO}\N{CIRCLED DIGIT THREE}" tests = [ diff --git a/examples/text_labels_and_annotations/tex_demo.py b/examples/text_labels_and_annotations/tex_demo.py index 44dbad90948b..4df40191660b 100644 --- a/examples/text_labels_and_annotations/tex_demo.py +++ b/examples/text_labels_and_annotations/tex_demo.py @@ -13,8 +13,8 @@ Unicode input is supported, e.g. for the y-axis label in this example. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np plt.rcParams['text.usetex'] = True diff --git a/examples/text_labels_and_annotations/text_fontdict.py b/examples/text_labels_and_annotations/text_fontdict.py index ad6fa8cc972b..b8ff4c7c9353 100644 --- a/examples/text_labels_and_annotations/text_fontdict.py +++ b/examples/text_labels_and_annotations/text_fontdict.py @@ -7,9 +7,8 @@ by creating a dictionary of options passed across several functions. """ -import numpy as np import matplotlib.pyplot as plt - +import numpy as np font = {'family': 'serif', 'color': 'darkred', diff --git a/examples/text_labels_and_annotations/usetex_baseline_test.py b/examples/text_labels_and_annotations/usetex_baseline_test.py index f40808b9f83e..49303e244821 100644 --- a/examples/text_labels_and_annotations/usetex_baseline_test.py +++ b/examples/text_labels_and_annotations/usetex_baseline_test.py @@ -8,7 +8,6 @@ import matplotlib.pyplot as plt - plt.rcParams.update({"mathtext.fontset": "cm", "mathtext.rm": "serif"}) axs = plt.figure(figsize=(2 * 3, 6.5)).subplots(1, 2) for ax, usetex in zip(axs, [False, True]): diff --git a/examples/text_labels_and_annotations/watermark_text.py b/examples/text_labels_and_annotations/watermark_text.py index 568a2b39f57a..12fa022cba9c 100644 --- a/examples/text_labels_and_annotations/watermark_text.py +++ b/examples/text_labels_and_annotations/watermark_text.py @@ -5,8 +5,8 @@ A watermark effect can be achieved by drawing a semi-transparent text. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np # Fixing random state for reproducibility np.random.seed(19680801) diff --git a/examples/ticks/auto_ticks.py b/examples/ticks/auto_ticks.py index 93f501b517d5..df7318b639d0 100644 --- a/examples/ticks/auto_ticks.py +++ b/examples/ticks/auto_ticks.py @@ -14,6 +14,7 @@ import matplotlib.pyplot as plt import numpy as np + np.random.seed(19680801) fig, ax = plt.subplots() diff --git a/examples/ticks/centered_ticklabels.py b/examples/ticks/centered_ticklabels.py index 11d3f0e8a9bc..37b63c25b173 100644 --- a/examples/ticks/centered_ticklabels.py +++ b/examples/ticks/centered_ticklabels.py @@ -17,11 +17,12 @@ Here is an example that labels the months, centered between the ticks. """ +import matplotlib.pyplot as plt import numpy as np + import matplotlib.cbook as cbook import matplotlib.dates as dates import matplotlib.ticker as ticker -import matplotlib.pyplot as plt # Load some financial data; Google's stock price r = (cbook.get_sample_data('goog.npz', np_load=True)['price_data'] diff --git a/examples/ticks/colorbar_tick_labelling_demo.py b/examples/ticks/colorbar_tick_labelling_demo.py index 9c3c375510d1..56294c6abbb3 100644 --- a/examples/ticks/colorbar_tick_labelling_demo.py +++ b/examples/ticks/colorbar_tick_labelling_demo.py @@ -10,9 +10,9 @@ import matplotlib.pyplot as plt import numpy as np -from matplotlib import cm from numpy.random import randn +from matplotlib import cm # Fixing random state for reproducibility np.random.seed(19680801) diff --git a/examples/ticks/date_concise_formatter.py b/examples/ticks/date_concise_formatter.py index 8b61fb13874b..e537b8307cf4 100644 --- a/examples/ticks/date_concise_formatter.py +++ b/examples/ticks/date_concise_formatter.py @@ -16,10 +16,12 @@ """ import datetime + import matplotlib.pyplot as plt -import matplotlib.dates as mdates import numpy as np +import matplotlib.dates as mdates + # %% # First, the default formatter. @@ -68,6 +70,7 @@ # imports: import matplotlib.units as munits + converter = mdates.ConciseDateConverter() munits.registry[np.datetime64] = converter munits.registry[datetime.date] = converter diff --git a/examples/ticks/date_demo_convert.py b/examples/ticks/date_demo_convert.py index 9d0b1695cb68..c22edf54df9a 100644 --- a/examples/ticks/date_demo_convert.py +++ b/examples/ticks/date_demo_convert.py @@ -5,10 +5,12 @@ """ import datetime + import matplotlib.pyplot as plt -from matplotlib.dates import DayLocator, HourLocator, DateFormatter, drange import numpy as np +from matplotlib.dates import DateFormatter, DayLocator, HourLocator, drange + date1 = datetime.datetime(2000, 3, 2) date2 = datetime.datetime(2000, 3, 6) delta = datetime.timedelta(hours=6) diff --git a/examples/ticks/date_demo_rrule.py b/examples/ticks/date_demo_rrule.py index c020a44c375b..eb1fb605640d 100644 --- a/examples/ticks/date_demo_rrule.py +++ b/examples/ticks/date_demo_rrule.py @@ -12,11 +12,13 @@ .. _iCalender RFC: https://tools.ietf.org/html/rfc5545 """ +import datetime + import matplotlib.pyplot as plt -from matplotlib.dates import (YEARLY, DateFormatter, - rrulewrapper, RRuleLocator, drange) import numpy as np -import datetime + +from matplotlib.dates import (YEARLY, DateFormatter, RRuleLocator, drange, + rrulewrapper) # Fixing random state for reproducibility np.random.seed(19680801) diff --git a/examples/ticks/date_formatters_locators.py b/examples/ticks/date_formatters_locators.py index 2adad036a034..d63d17d51f27 100644 --- a/examples/ticks/date_formatters_locators.py +++ b/examples/ticks/date_formatters_locators.py @@ -7,15 +7,16 @@ formatters. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np + +from matplotlib.dates import (FR, MO, MONTHLY, SA, SU, TH, TU, WE, + AutoDateFormatter, AutoDateLocator, + ConciseDateFormatter, DateFormatter, DayLocator, + HourLocator, MicrosecondLocator, MinuteLocator, + MonthLocator, RRuleLocator, SecondLocator, + WeekdayLocator, YearLocator, rrulewrapper) import matplotlib.ticker as ticker -from matplotlib.dates import (AutoDateLocator, YearLocator, MonthLocator, - DayLocator, WeekdayLocator, HourLocator, - MinuteLocator, SecondLocator, MicrosecondLocator, - RRuleLocator, rrulewrapper, MONTHLY, - MO, TU, WE, TH, FR, SA, SU, DateFormatter, - AutoDateFormatter, ConciseDateFormatter) locators = [ ('AutoDateLocator(maxticks=8)', '2003-02-01', '%Y-%m'), diff --git a/examples/ticks/date_index_formatter.py b/examples/ticks/date_index_formatter.py index 4eb9556f1cdf..f63e0fff9485 100644 --- a/examples/ticks/date_index_formatter.py +++ b/examples/ticks/date_index_formatter.py @@ -13,14 +13,14 @@ The example shows how to use an 'index formatter' to achieve the desired plot. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np + import matplotlib.cbook as cbook -import matplotlib.lines as ml from matplotlib.dates import DateFormatter, DayLocator +import matplotlib.lines as ml from matplotlib.ticker import Formatter - # Load a numpy record array from yahoo csv data with fields date, open, high, # low, close, volume, adj_close from the mpl-data/sample_data directory. The # record array stores the date as an np.datetime64 with a day unit ('D') in diff --git a/examples/ticks/date_precision_and_epochs.py b/examples/ticks/date_precision_and_epochs.py index 8afe86af92c0..aaaf37019f9e 100644 --- a/examples/ticks/date_precision_and_epochs.py +++ b/examples/ticks/date_precision_and_epochs.py @@ -18,9 +18,10 @@ """ import datetime -import numpy as np import matplotlib.pyplot as plt +import numpy as np + import matplotlib.dates as mdates diff --git a/examples/ticks/dollar_ticks.py b/examples/ticks/dollar_ticks.py index 21cb26928caa..4186e8c369e9 100644 --- a/examples/ticks/dollar_ticks.py +++ b/examples/ticks/dollar_ticks.py @@ -7,8 +7,8 @@ .. redirect-from:: /gallery/pyplots/dollar_ticks """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np # Fixing random state for reproducibility np.random.seed(19680801) diff --git a/examples/ticks/major_minor_demo.py b/examples/ticks/major_minor_demo.py index c5234225b796..9fd93118a9ac 100644 --- a/examples/ticks/major_minor_demo.py +++ b/examples/ticks/major_minor_demo.py @@ -33,8 +33,8 @@ import matplotlib.pyplot as plt import numpy as np -from matplotlib.ticker import (MultipleLocator, AutoMinorLocator) +from matplotlib.ticker import AutoMinorLocator, MultipleLocator t = np.arange(0.0, 100.0, 0.1) s = np.sin(0.1 * np.pi * t) * np.exp(-t * 0.01) diff --git a/examples/ticks/tick-formatters.py b/examples/ticks/tick-formatters.py index e0a4005ee93b..45f59d0b48c2 100644 --- a/examples/ticks/tick-formatters.py +++ b/examples/ticks/tick-formatters.py @@ -11,6 +11,7 @@ """ import matplotlib.pyplot as plt + from matplotlib import ticker diff --git a/examples/ticks/tick-locators.py b/examples/ticks/tick-locators.py index 1832f382529e..b1f66e7eba44 100644 --- a/examples/ticks/tick-locators.py +++ b/examples/ticks/tick-locators.py @@ -8,8 +8,9 @@ This example illustrates the usage and effect of the most common locators. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np + import matplotlib.ticker as ticker diff --git a/examples/ticks/tick_labels_from_values.py b/examples/ticks/tick_labels_from_values.py index 247fc817eace..0d40597e6261 100644 --- a/examples/ticks/tick_labels_from_values.py +++ b/examples/ticks/tick_labels_from_values.py @@ -16,8 +16,8 @@ """ import matplotlib.pyplot as plt -from matplotlib.ticker import MaxNLocator +from matplotlib.ticker import MaxNLocator fig, ax = plt.subplots() xs = range(26) diff --git a/examples/ticks/ticklabels_rotation.py b/examples/ticks/ticklabels_rotation.py index 3a2fd07442ee..711a680def62 100644 --- a/examples/ticks/ticklabels_rotation.py +++ b/examples/ticks/ticklabels_rotation.py @@ -7,7 +7,6 @@ """ import matplotlib.pyplot as plt - x = [1, 2, 3, 4] y = [1, 4, 9, 6] labels = ['Frogs', 'Hogs', 'Bogs', 'Slogs'] diff --git a/examples/units/annotate_with_units.py b/examples/units/annotate_with_units.py index cd4e47ddaf12..1a007e986465 100644 --- a/examples/units/annotate_with_units.py +++ b/examples/units/annotate_with_units.py @@ -11,9 +11,10 @@ This example requires :download:`basic_units.py ` """ -import matplotlib.pyplot as plt from basic_units import cm +import matplotlib.pyplot as plt + fig, ax = plt.subplots() ax.annotate("Note 01", [0.5*cm, 0.5*cm]) diff --git a/examples/units/artist_tests.py b/examples/units/artist_tests.py index 0b078ce5cb6f..a6c56954b0c8 100644 --- a/examples/units/artist_tests.py +++ b/examples/units/artist_tests.py @@ -15,14 +15,16 @@ This example requires :download:`basic_units.py ` """ import random -import matplotlib.lines as lines -import matplotlib.patches as patches -import matplotlib.text as text -import matplotlib.collections as collections from basic_units import cm, inch -import numpy as np + import matplotlib.pyplot as plt +import numpy as np + +import matplotlib.collections as collections +import matplotlib.lines as lines +import matplotlib.patches as patches +import matplotlib.text as text fig, ax = plt.subplots() ax.xaxis.set_units(cm) diff --git a/examples/units/bar_demo2.py b/examples/units/bar_demo2.py index d18f81b77535..7c0c8215eca4 100644 --- a/examples/units/bar_demo2.py +++ b/examples/units/bar_demo2.py @@ -13,9 +13,10 @@ This example requires :download:`basic_units.py ` """ -import numpy as np from basic_units import cm, inch + import matplotlib.pyplot as plt +import numpy as np cms = cm * np.arange(0, 10, 2) bottom = 0 * cm diff --git a/examples/units/bar_unit_demo.py b/examples/units/bar_unit_demo.py index b64784cc5c07..18e2c00b699e 100644 --- a/examples/units/bar_unit_demo.py +++ b/examples/units/bar_unit_demo.py @@ -12,10 +12,10 @@ This example requires :download:`basic_units.py ` """ -import numpy as np from basic_units import cm, inch -import matplotlib.pyplot as plt +import matplotlib.pyplot as plt +import numpy as np N = 5 tea_means = [15*cm, 10*cm, 8*cm, 12*cm, 5*cm] diff --git a/examples/units/basic_units.py b/examples/units/basic_units.py index 95df58ccf0c4..e9b5d18ef340 100644 --- a/examples/units/basic_units.py +++ b/examples/units/basic_units.py @@ -7,11 +7,12 @@ import math -import numpy as np from packaging.version import parse as parse_version -import matplotlib.units as units +import numpy as np + import matplotlib.ticker as ticker +import matplotlib.units as units class ProxyDelegate: diff --git a/examples/units/ellipse_with_units.py b/examples/units/ellipse_with_units.py index 86ac6cebf8ee..e4518c90eeb9 100644 --- a/examples/units/ellipse_with_units.py +++ b/examples/units/ellipse_with_units.py @@ -11,10 +11,11 @@ """ from basic_units import cm -import numpy as np -from matplotlib import patches + import matplotlib.pyplot as plt +import numpy as np +from matplotlib import patches xcenter, ycenter = 0.38*cm, 0.52*cm width, height = 1e-1*cm, 3e-1*cm diff --git a/examples/units/evans_test.py b/examples/units/evans_test.py index 3a4ac2fe7f55..838d61151548 100644 --- a/examples/units/evans_test.py +++ b/examples/units/evans_test.py @@ -9,11 +9,11 @@ to what kind of units client packages use. """ +import matplotlib.pyplot as plt import numpy as np -import matplotlib.units as units import matplotlib.ticker as ticker -import matplotlib.pyplot as plt +import matplotlib.units as units class Foo: diff --git a/examples/units/radian_demo.py b/examples/units/radian_demo.py index f9da342defcd..492a1e971c55 100644 --- a/examples/units/radian_demo.py +++ b/examples/units/radian_demo.py @@ -14,11 +14,11 @@ This example requires :download:`basic_units.py ` """ +from basic_units import cos, degrees, radians + import matplotlib.pyplot as plt import numpy as np -from basic_units import radians, degrees, cos - x = [val*radians for val in np.arange(0, 15, 0.01)] fig, axs = plt.subplots(2) diff --git a/examples/units/units_sample.py b/examples/units/units_sample.py index 81547601e711..5c3443a47125 100644 --- a/examples/units/units_sample.py +++ b/examples/units/units_sample.py @@ -14,6 +14,7 @@ """ from basic_units import cm, inch + import matplotlib.pyplot as plt import numpy as np diff --git a/examples/units/units_scatter.py b/examples/units/units_scatter.py index 8a121b4afd0f..bcaf2c6bee18 100644 --- a/examples/units/units_scatter.py +++ b/examples/units/units_scatter.py @@ -10,9 +10,10 @@ This example requires :download:`basic_units.py ` """ -import numpy as np +from basic_units import hertz, minutes, secs + import matplotlib.pyplot as plt -from basic_units import secs, hertz, minutes +import numpy as np # create masked array data = (1, 2, 3, 4, 5, 6, 7, 8) diff --git a/examples/user_interfaces/canvasagg.py b/examples/user_interfaces/canvasagg.py index b72d9bc1ee6e..0e460cc64539 100644 --- a/examples/user_interfaces/canvasagg.py +++ b/examples/user_interfaces/canvasagg.py @@ -24,11 +24,12 @@ .. redirect-from:: /gallery/misc/agg_buffer_to_array """ -from matplotlib.backends.backend_agg import FigureCanvasAgg -from matplotlib.figure import Figure -import numpy as np from PIL import Image +import numpy as np + +from matplotlib.backends.backend_agg import FigureCanvasAgg +from matplotlib.figure import Figure fig = Figure(figsize=(5, 4), dpi=100) # A canvas must be manually attached to the figure (pyplot would automatically diff --git a/examples/user_interfaces/embedding_in_gtk3_panzoom_sgskip.py b/examples/user_interfaces/embedding_in_gtk3_panzoom_sgskip.py index 7009b55bada7..f6892a849a88 100644 --- a/examples/user_interfaces/embedding_in_gtk3_panzoom_sgskip.py +++ b/examples/user_interfaces/embedding_in_gtk3_panzoom_sgskip.py @@ -7,16 +7,18 @@ """ import gi + gi.require_version('Gtk', '3.0') from gi.repository import Gtk -from matplotlib.backends.backend_gtk3 import ( - NavigationToolbar2GTK3 as NavigationToolbar) -from matplotlib.backends.backend_gtk3agg import ( - FigureCanvasGTK3Agg as FigureCanvas) -from matplotlib.figure import Figure import numpy as np +from matplotlib.backends.backend_gtk3 import \ + NavigationToolbar2GTK3 as NavigationToolbar +from matplotlib.backends.backend_gtk3agg import \ + FigureCanvasGTK3Agg as FigureCanvas +from matplotlib.figure import Figure + win = Gtk.Window() win.connect("delete-event", Gtk.main_quit) win.set_default_size(400, 300) diff --git a/examples/user_interfaces/embedding_in_gtk3_sgskip.py b/examples/user_interfaces/embedding_in_gtk3_sgskip.py index b672ba8d9ff0..170a88a58aff 100644 --- a/examples/user_interfaces/embedding_in_gtk3_sgskip.py +++ b/examples/user_interfaces/embedding_in_gtk3_sgskip.py @@ -8,14 +8,16 @@ """ import gi + gi.require_version('Gtk', '3.0') from gi.repository import Gtk -from matplotlib.backends.backend_gtk3agg import ( - FigureCanvasGTK3Agg as FigureCanvas) -from matplotlib.figure import Figure import numpy as np +from matplotlib.backends.backend_gtk3agg import \ + FigureCanvasGTK3Agg as FigureCanvas +from matplotlib.figure import Figure + win = Gtk.Window() win.connect("delete-event", Gtk.main_quit) win.set_default_size(400, 300) diff --git a/examples/user_interfaces/embedding_in_gtk4_panzoom_sgskip.py b/examples/user_interfaces/embedding_in_gtk4_panzoom_sgskip.py index b132aff1074f..3e8568091236 100644 --- a/examples/user_interfaces/embedding_in_gtk4_panzoom_sgskip.py +++ b/examples/user_interfaces/embedding_in_gtk4_panzoom_sgskip.py @@ -7,16 +7,18 @@ """ import gi + gi.require_version('Gtk', '4.0') from gi.repository import Gtk -from matplotlib.backends.backend_gtk4 import ( - NavigationToolbar2GTK4 as NavigationToolbar) -from matplotlib.backends.backend_gtk4agg import ( - FigureCanvasGTK4Agg as FigureCanvas) -from matplotlib.figure import Figure import numpy as np +from matplotlib.backends.backend_gtk4 import \ + NavigationToolbar2GTK4 as NavigationToolbar +from matplotlib.backends.backend_gtk4agg import \ + FigureCanvasGTK4Agg as FigureCanvas +from matplotlib.figure import Figure + def on_activate(app): win = Gtk.ApplicationWindow(application=app) diff --git a/examples/user_interfaces/embedding_in_gtk4_sgskip.py b/examples/user_interfaces/embedding_in_gtk4_sgskip.py index c92e139de25f..0e17473de5d3 100644 --- a/examples/user_interfaces/embedding_in_gtk4_sgskip.py +++ b/examples/user_interfaces/embedding_in_gtk4_sgskip.py @@ -8,14 +8,16 @@ """ import gi + gi.require_version('Gtk', '4.0') from gi.repository import Gtk -from matplotlib.backends.backend_gtk4agg import ( - FigureCanvasGTK4Agg as FigureCanvas) -from matplotlib.figure import Figure import numpy as np +from matplotlib.backends.backend_gtk4agg import \ + FigureCanvasGTK4Agg as FigureCanvas +from matplotlib.figure import Figure + def on_activate(app): win = Gtk.ApplicationWindow(application=app) diff --git a/examples/user_interfaces/embedding_in_qt_sgskip.py b/examples/user_interfaces/embedding_in_qt_sgskip.py index 32529739ac14..b79f582a65e4 100644 --- a/examples/user_interfaces/embedding_in_qt_sgskip.py +++ b/examples/user_interfaces/embedding_in_qt_sgskip.py @@ -14,9 +14,10 @@ import numpy as np +from matplotlib.backends.backend_qtagg import FigureCanvas +from matplotlib.backends.backend_qtagg import \ + NavigationToolbar2QT as NavigationToolbar from matplotlib.backends.qt_compat import QtWidgets -from matplotlib.backends.backend_qtagg import ( - FigureCanvas, NavigationToolbar2QT as NavigationToolbar) from matplotlib.figure import Figure diff --git a/examples/user_interfaces/embedding_in_tk_sgskip.py b/examples/user_interfaces/embedding_in_tk_sgskip.py index 55fb2b48b5d6..e5c4aa4125b6 100644 --- a/examples/user_interfaces/embedding_in_tk_sgskip.py +++ b/examples/user_interfaces/embedding_in_tk_sgskip.py @@ -7,15 +7,14 @@ import tkinter -from matplotlib.backends.backend_tkagg import ( - FigureCanvasTkAgg, NavigationToolbar2Tk) +import numpy as np + # Implement the default Matplotlib key bindings. from matplotlib.backend_bases import key_press_handler +from matplotlib.backends.backend_tkagg import (FigureCanvasTkAgg, + NavigationToolbar2Tk) from matplotlib.figure import Figure -import numpy as np - - root = tkinter.Tk() root.wm_title("Embedding in Tk") diff --git a/examples/user_interfaces/embedding_in_wx2_sgskip.py b/examples/user_interfaces/embedding_in_wx2_sgskip.py index fcebeeee8cd6..acfe1bc9d98f 100644 --- a/examples/user_interfaces/embedding_in_wx2_sgskip.py +++ b/examples/user_interfaces/embedding_in_wx2_sgskip.py @@ -7,15 +7,15 @@ toolbar - comment out the add_toolbar line for no toolbar. """ -from matplotlib.backends.backend_wxagg import ( - FigureCanvasWxAgg as FigureCanvas, - NavigationToolbar2WxAgg as NavigationToolbar) -from matplotlib.figure import Figure +import wx +import wx.lib.mixins.inspection as WIT import numpy as np -import wx -import wx.lib.mixins.inspection as WIT +from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas +from matplotlib.backends.backend_wxagg import \ + NavigationToolbar2WxAgg as NavigationToolbar +from matplotlib.figure import Figure class CanvasFrame(wx.Frame): diff --git a/examples/user_interfaces/embedding_in_wx3_sgskip.py b/examples/user_interfaces/embedding_in_wx3_sgskip.py index ec596aba0478..40282699d872 100644 --- a/examples/user_interfaces/embedding_in_wx3_sgskip.py +++ b/examples/user_interfaces/embedding_in_wx3_sgskip.py @@ -21,17 +21,18 @@ Thanks to matplotlib and wx teams for creating such great software! """ -import matplotlib.cm as cm -import matplotlib.cbook as cbook -from matplotlib.backends.backend_wxagg import ( - FigureCanvasWxAgg as FigureCanvas, - NavigationToolbar2WxAgg as NavigationToolbar) -from matplotlib.figure import Figure -import numpy as np - import wx import wx.xrc as xrc +import numpy as np + +from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas +from matplotlib.backends.backend_wxagg import \ + NavigationToolbar2WxAgg as NavigationToolbar +import matplotlib.cbook as cbook +import matplotlib.cm as cm +from matplotlib.figure import Figure + ERR_TOL = 1e-5 # floating point slop for peak-detection diff --git a/examples/user_interfaces/embedding_in_wx4_sgskip.py b/examples/user_interfaces/embedding_in_wx4_sgskip.py index 69922046c49f..56cb5f423980 100644 --- a/examples/user_interfaces/embedding_in_wx4_sgskip.py +++ b/examples/user_interfaces/embedding_in_wx4_sgskip.py @@ -6,15 +6,14 @@ An example of how to use wxagg in a wx application with a custom toolbar. """ -from matplotlib.backends.backend_wxagg import ( - FigureCanvasWxAgg as FigureCanvas, - NavigationToolbar2WxAgg as NavigationToolbar, -) -from matplotlib.figure import Figure +import wx import numpy as np -import wx +from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas +from matplotlib.backends.backend_wxagg import \ + NavigationToolbar2WxAgg as NavigationToolbar +from matplotlib.figure import Figure class MyNavigationToolbar(NavigationToolbar): diff --git a/examples/user_interfaces/embedding_in_wx5_sgskip.py b/examples/user_interfaces/embedding_in_wx5_sgskip.py index c3c3d91f7368..80062782d9fa 100644 --- a/examples/user_interfaces/embedding_in_wx5_sgskip.py +++ b/examples/user_interfaces/embedding_in_wx5_sgskip.py @@ -9,10 +9,10 @@ import wx.lib.agw.aui as aui import wx.lib.mixins.inspection as wit +from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas +from matplotlib.backends.backend_wxagg import \ + NavigationToolbar2WxAgg as NavigationToolbar from matplotlib.figure import Figure -from matplotlib.backends.backend_wxagg import ( - FigureCanvasWxAgg as FigureCanvas, - NavigationToolbar2WxAgg as NavigationToolbar) class Plot(wx.Panel): diff --git a/examples/user_interfaces/embedding_webagg_sgskip.py b/examples/user_interfaces/embedding_webagg_sgskip.py index 15a2dd95b3ba..cdeb6419a18e 100644 --- a/examples/user_interfaces/embedding_webagg_sgskip.py +++ b/examples/user_interfaces/embedding_webagg_sgskip.py @@ -23,19 +23,18 @@ import tornado except ImportError as err: raise RuntimeError("This example requires tornado.") from err -import tornado.web import tornado.httpserver import tornado.ioloop +import tornado.web import tornado.websocket +import numpy as np import matplotlib as mpl from matplotlib.backends.backend_webagg import ( FigureManagerWebAgg, new_figure_manager_given_figure) from matplotlib.figure import Figure -import numpy as np - def create_figure(): """ diff --git a/examples/user_interfaces/fourier_demo_wx_sgskip.py b/examples/user_interfaces/fourier_demo_wx_sgskip.py index 392fbb10f9a3..56c62ae1ba77 100644 --- a/examples/user_interfaces/fourier_demo_wx_sgskip.py +++ b/examples/user_interfaces/fourier_demo_wx_sgskip.py @@ -5,9 +5,10 @@ """ +import wx + import numpy as np -import wx from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas from matplotlib.figure import Figure diff --git a/examples/user_interfaces/gtk3_spreadsheet_sgskip.py b/examples/user_interfaces/gtk3_spreadsheet_sgskip.py index 4261d9ac1e89..bd95deaabba3 100644 --- a/examples/user_interfaces/gtk3_spreadsheet_sgskip.py +++ b/examples/user_interfaces/gtk3_spreadsheet_sgskip.py @@ -8,13 +8,14 @@ """ import gi + gi.require_version('Gtk', '3.0') gi.require_version('Gdk', '3.0') -from gi.repository import Gtk, Gdk - -from matplotlib.backends.backend_gtk3agg import FigureCanvas # or gtk3cairo. +from gi.repository import Gdk, Gtk from numpy.random import random + +from matplotlib.backends.backend_gtk3agg import FigureCanvas # or gtk3cairo. from matplotlib.figure import Figure diff --git a/examples/user_interfaces/gtk4_spreadsheet_sgskip.py b/examples/user_interfaces/gtk4_spreadsheet_sgskip.py index 509789f5aedb..713fdc4e0f6e 100644 --- a/examples/user_interfaces/gtk4_spreadsheet_sgskip.py +++ b/examples/user_interfaces/gtk4_spreadsheet_sgskip.py @@ -8,13 +8,14 @@ """ import gi + gi.require_version('Gtk', '4.0') gi.require_version('Gdk', '4.0') from gi.repository import Gtk -from matplotlib.backends.backend_gtk4agg import FigureCanvas # or gtk4cairo. - from numpy.random import random + +from matplotlib.backends.backend_gtk4agg import FigureCanvas # or gtk4cairo. from matplotlib.figure import Figure diff --git a/examples/user_interfaces/mathtext_wx_sgskip.py b/examples/user_interfaces/mathtext_wx_sgskip.py index f9af7a89c416..5d3c5c6bc46d 100644 --- a/examples/user_interfaces/mathtext_wx_sgskip.py +++ b/examples/user_interfaces/mathtext_wx_sgskip.py @@ -9,11 +9,13 @@ from io import BytesIO -from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas +import wx + +import numpy as np + from matplotlib.backends.backend_wx import NavigationToolbar2Wx +from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas from matplotlib.figure import Figure -import numpy as np -import wx IS_WIN = 'wxMSW' in wx.PlatformInfo diff --git a/examples/user_interfaces/mpl_with_glade3_sgskip.py b/examples/user_interfaces/mpl_with_glade3_sgskip.py index 5e6a43caca61..f39dbf4ca28e 100644 --- a/examples/user_interfaces/mpl_with_glade3_sgskip.py +++ b/examples/user_interfaces/mpl_with_glade3_sgskip.py @@ -7,13 +7,16 @@ from pathlib import Path import gi + gi.require_version('Gtk', '3.0') from gi.repository import Gtk -from matplotlib.figure import Figure -from matplotlib.backends.backend_gtk3agg import ( - FigureCanvasGTK3Agg as FigureCanvas) + import numpy as np +from matplotlib.backends.backend_gtk3agg import \ + FigureCanvasGTK3Agg as FigureCanvas +from matplotlib.figure import Figure + class Window1Signals: def on_window1_destroy(self, widget): diff --git a/examples/user_interfaces/mplcvd.py b/examples/user_interfaces/mplcvd.py index 8eaa22a8977a..78decd8a4927 100644 --- a/examples/user_interfaces/mplcvd.py +++ b/examples/user_interfaces/mplcvd.py @@ -11,8 +11,8 @@ from pathlib import Path import colorspacious -import numpy as np +import numpy as np _BUTTON_NAME = "Filter" _BUTTON_HELP = "Simulate color vision deficiencies" @@ -256,6 +256,7 @@ def _setup_wx(tb): if __name__ == '__main__': import matplotlib.pyplot as plt + from matplotlib import cbook plt.rcParams['figure.hooks'].append('mplcvd:setup') diff --git a/examples/user_interfaces/pylab_with_gtk3_sgskip.py b/examples/user_interfaces/pylab_with_gtk3_sgskip.py index 4d943032df5a..e86e2a75d629 100644 --- a/examples/user_interfaces/pylab_with_gtk3_sgskip.py +++ b/examples/user_interfaces/pylab_with_gtk3_sgskip.py @@ -8,14 +8,15 @@ """ import matplotlib + matplotlib.use('GTK3Agg') # or 'GTK3Cairo' +import gi + import matplotlib.pyplot as plt -import gi gi.require_version('Gtk', '3.0') from gi.repository import Gtk - fig, ax = plt.subplots() ax.plot([1, 2, 3], 'ro-', label='easy as 1 2 3') ax.plot([1, 4, 9], 'gs--', label='easy as 1 2 3 squared') diff --git a/examples/user_interfaces/pylab_with_gtk4_sgskip.py b/examples/user_interfaces/pylab_with_gtk4_sgskip.py index 6e0cebcce23c..0d449530934e 100644 --- a/examples/user_interfaces/pylab_with_gtk4_sgskip.py +++ b/examples/user_interfaces/pylab_with_gtk4_sgskip.py @@ -8,14 +8,15 @@ """ import matplotlib + matplotlib.use('GTK4Agg') # or 'GTK4Cairo' +import gi + import matplotlib.pyplot as plt -import gi gi.require_version('Gtk', '4.0') from gi.repository import Gtk - fig, ax = plt.subplots() ax.plot([1, 2, 3], 'ro-', label='easy as 1 2 3') ax.plot([1, 4, 9], 'gs--', label='easy as 1 2 3 squared') diff --git a/examples/user_interfaces/svg_histogram_sgskip.py b/examples/user_interfaces/svg_histogram_sgskip.py index eb4a9db25cfc..38546b4cb4c3 100644 --- a/examples/user_interfaces/svg_histogram_sgskip.py +++ b/examples/user_interfaces/svg_histogram_sgskip.py @@ -34,12 +34,12 @@ """ -import numpy as np -import matplotlib.pyplot as plt -import xml.etree.ElementTree as ET from io import BytesIO import json +import xml.etree.ElementTree as ET +import matplotlib.pyplot as plt +import numpy as np plt.rcParams['svg.fonttype'] = 'none' diff --git a/examples/user_interfaces/svg_tooltip_sgskip.py b/examples/user_interfaces/svg_tooltip_sgskip.py index a709428374c0..7068431b45e8 100644 --- a/examples/user_interfaces/svg_tooltip_sgskip.py +++ b/examples/user_interfaces/svg_tooltip_sgskip.py @@ -23,9 +23,10 @@ """ -import matplotlib.pyplot as plt -import xml.etree.ElementTree as ET from io import BytesIO +import xml.etree.ElementTree as ET + +import matplotlib.pyplot as plt ET.register_namespace("", "http://www.w3.org/2000/svg") diff --git a/examples/user_interfaces/toolmanager_sgskip.py b/examples/user_interfaces/toolmanager_sgskip.py index 254a8f1747d7..14fc671a5301 100644 --- a/examples/user_interfaces/toolmanager_sgskip.py +++ b/examples/user_interfaces/toolmanager_sgskip.py @@ -14,8 +14,8 @@ """ import matplotlib.pyplot as plt -from matplotlib.backend_tools import ToolBase, ToolToggleBase +from matplotlib.backend_tools import ToolBase, ToolToggleBase plt.rcParams['toolbar'] = 'toolmanager' diff --git a/examples/user_interfaces/web_application_server_sgskip.py b/examples/user_interfaces/web_application_server_sgskip.py index 30196d419317..950109015191 100644 --- a/examples/user_interfaces/web_application_server_sgskip.py +++ b/examples/user_interfaces/web_application_server_sgskip.py @@ -23,6 +23,7 @@ from io import BytesIO from flask import Flask + from matplotlib.figure import Figure app = Flask(__name__) diff --git a/examples/user_interfaces/wxcursor_demo_sgskip.py b/examples/user_interfaces/wxcursor_demo_sgskip.py index ae1e06c81a01..96c6d760dc5d 100644 --- a/examples/user_interfaces/wxcursor_demo_sgskip.py +++ b/examples/user_interfaces/wxcursor_demo_sgskip.py @@ -6,12 +6,13 @@ Example to draw a cursor and report the data coords in wx. """ -from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas -from matplotlib.backends.backend_wx import NavigationToolbar2Wx -from matplotlib.figure import Figure +import wx + import numpy as np -import wx +from matplotlib.backends.backend_wx import NavigationToolbar2Wx +from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas +from matplotlib.figure import Figure class CanvasFrame(wx.Frame): diff --git a/examples/userdemo/annotate_explain.py b/examples/userdemo/annotate_explain.py index c64107985271..8f20b5406bd7 100644 --- a/examples/userdemo/annotate_explain.py +++ b/examples/userdemo/annotate_explain.py @@ -6,8 +6,8 @@ """ import matplotlib.pyplot as plt -import matplotlib.patches as mpatches +import matplotlib.patches as mpatches fig, axs = plt.subplots(2, 2) x1, y1 = 0.3, 0.3 diff --git a/examples/userdemo/annotate_simple_coord02.py b/examples/userdemo/annotate_simple_coord02.py index 869b5a63ba03..18eca0ad88a4 100644 --- a/examples/userdemo/annotate_simple_coord02.py +++ b/examples/userdemo/annotate_simple_coord02.py @@ -7,7 +7,6 @@ import matplotlib.pyplot as plt - fig, ax = plt.subplots(figsize=(3, 2)) an1 = ax.annotate("Test 1", xy=(0.5, 0.5), xycoords="data", va="center", ha="center", diff --git a/examples/userdemo/annotate_text_arrow.py b/examples/userdemo/annotate_text_arrow.py index afe3164a0213..2495c7687bd7 100644 --- a/examples/userdemo/annotate_text_arrow.py +++ b/examples/userdemo/annotate_text_arrow.py @@ -5,9 +5,8 @@ """ -import numpy as np import matplotlib.pyplot as plt - +import numpy as np # Fixing random state for reproducibility np.random.seed(19680801) diff --git a/examples/userdemo/connect_simple01.py b/examples/userdemo/connect_simple01.py index f8769e39401f..ab0e036713c0 100644 --- a/examples/userdemo/connect_simple01.py +++ b/examples/userdemo/connect_simple01.py @@ -7,9 +7,10 @@ between points defined in different coordinate systems and/or axes. """ -from matplotlib.patches import ConnectionPatch import matplotlib.pyplot as plt +from matplotlib.patches import ConnectionPatch + fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(6, 3)) # Draw a simple arrow between two points in axes coordinates diff --git a/examples/userdemo/custom_boxstyle01.py b/examples/userdemo/custom_boxstyle01.py index 54fc19b16fef..71668cc6cc31 100644 --- a/examples/userdemo/custom_boxstyle01.py +++ b/examples/userdemo/custom_boxstyle01.py @@ -7,10 +7,10 @@ Custom `.ConnectionStyle`\s and `.ArrowStyle`\s can be similarly defined. """ -from matplotlib.patches import BoxStyle -from matplotlib.path import Path import matplotlib.pyplot as plt +from matplotlib.patches import BoxStyle +from matplotlib.path import Path # %% # Custom box styles can be implemented as a function that takes arguments diff --git a/examples/userdemo/demo_gridspec03.py b/examples/userdemo/demo_gridspec03.py index 368576d85b59..63951ef7d563 100644 --- a/examples/userdemo/demo_gridspec03.py +++ b/examples/userdemo/demo_gridspec03.py @@ -11,6 +11,7 @@ """ import matplotlib.pyplot as plt + from matplotlib.gridspec import GridSpec diff --git a/examples/userdemo/pgf_fonts.py b/examples/userdemo/pgf_fonts.py index 112c249752c2..9d5f5594b81b 100644 --- a/examples/userdemo/pgf_fonts.py +++ b/examples/userdemo/pgf_fonts.py @@ -5,6 +5,7 @@ """ import matplotlib.pyplot as plt + plt.rcParams.update({ "font.family": "serif", # Use LaTeX default serif font. diff --git a/examples/userdemo/pgf_preamble_sgskip.py b/examples/userdemo/pgf_preamble_sgskip.py index ca193a0aecc0..b32fa972c31f 100644 --- a/examples/userdemo/pgf_preamble_sgskip.py +++ b/examples/userdemo/pgf_preamble_sgskip.py @@ -5,8 +5,10 @@ """ import matplotlib as mpl + mpl.use("pgf") import matplotlib.pyplot as plt + plt.rcParams.update({ "font.family": "serif", # use serif/main font for text elements "text.usetex": True, # use inline math for ticks diff --git a/examples/userdemo/pgf_texsystem.py b/examples/userdemo/pgf_texsystem.py index 20f35b5cc906..0d8e326803ea 100644 --- a/examples/userdemo/pgf_texsystem.py +++ b/examples/userdemo/pgf_texsystem.py @@ -5,6 +5,7 @@ """ import matplotlib.pyplot as plt + plt.rcParams.update({ "pgf.texsystem": "pdflatex", "pgf.preamble": "\n".join([ diff --git a/examples/userdemo/simple_annotate01.py b/examples/userdemo/simple_annotate01.py index b7f1125eb251..cb3b6cb7e2c8 100644 --- a/examples/userdemo/simple_annotate01.py +++ b/examples/userdemo/simple_annotate01.py @@ -6,8 +6,8 @@ """ import matplotlib.pyplot as plt -import matplotlib.patches as mpatches +import matplotlib.patches as mpatches fig, axs = plt.subplots(2, 4) x1, y1 = 0.3, 0.3 diff --git a/examples/userdemo/simple_legend01.py b/examples/userdemo/simple_legend01.py index 2aaac1424558..6c74597ee5cc 100644 --- a/examples/userdemo/simple_legend01.py +++ b/examples/userdemo/simple_legend01.py @@ -6,7 +6,6 @@ """ import matplotlib.pyplot as plt - fig = plt.figure() ax = fig.add_subplot(211) diff --git a/examples/widgets/annotated_cursor.py b/examples/widgets/annotated_cursor.py index a10a010942e0..9fec9b6568bc 100644 --- a/examples/widgets/annotated_cursor.py +++ b/examples/widgets/annotated_cursor.py @@ -20,11 +20,11 @@ movement, which triggers the cursor creation, is missing. """ -from matplotlib.widgets import Cursor -import numpy as np import matplotlib.pyplot as plt +import numpy as np from matplotlib.backend_bases import MouseEvent +from matplotlib.widgets import Cursor class AnnotatedCursor(Cursor): diff --git a/examples/widgets/buttons.py b/examples/widgets/buttons.py index 8ea5deb1870e..61249522c72c 100644 --- a/examples/widgets/buttons.py +++ b/examples/widgets/buttons.py @@ -9,8 +9,9 @@ new frequencies. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np + from matplotlib.widgets import Button freqs = np.arange(2, 20, 3) diff --git a/examples/widgets/check_buttons.py b/examples/widgets/check_buttons.py index 934e0ecfefb2..f747d5f52145 100644 --- a/examples/widgets/check_buttons.py +++ b/examples/widgets/check_buttons.py @@ -10,8 +10,9 @@ waves are displayed with the check buttons. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np + from matplotlib.widgets import CheckButtons t = np.arange(0.0, 2.0, 0.01) diff --git a/examples/widgets/cursor.py b/examples/widgets/cursor.py index eb78d152206f..af7d821fbf10 100644 --- a/examples/widgets/cursor.py +++ b/examples/widgets/cursor.py @@ -4,10 +4,10 @@ ====== """ -from matplotlib.widgets import Cursor -import numpy as np import matplotlib.pyplot as plt +import numpy as np +from matplotlib.widgets import Cursor # Fixing random state for reproducibility np.random.seed(19680801) diff --git a/examples/widgets/lasso_selector_demo_sgskip.py b/examples/widgets/lasso_selector_demo_sgskip.py index df4c95dde4f4..fd2459be4f4f 100644 --- a/examples/widgets/lasso_selector_demo_sgskip.py +++ b/examples/widgets/lasso_selector_demo_sgskip.py @@ -13,8 +13,8 @@ import numpy as np -from matplotlib.widgets import LassoSelector from matplotlib.path import Path +from matplotlib.widgets import LassoSelector class SelectFromCollection: diff --git a/examples/widgets/menu.py b/examples/widgets/menu.py index 154182d5ae36..b8f5268a6477 100644 --- a/examples/widgets/menu.py +++ b/examples/widgets/menu.py @@ -5,9 +5,10 @@ """ +import matplotlib.pyplot as plt + import matplotlib.artist as artist import matplotlib.patches as patches -import matplotlib.pyplot as plt from matplotlib.transforms import IdentityTransform diff --git a/examples/widgets/mouse_cursor.py b/examples/widgets/mouse_cursor.py index 573fa7da834c..2ac1b10dac58 100644 --- a/examples/widgets/mouse_cursor.py +++ b/examples/widgets/mouse_cursor.py @@ -9,8 +9,8 @@ """ import matplotlib.pyplot as plt -from matplotlib.backend_tools import Cursors +from matplotlib.backend_tools import Cursors fig, axs = plt.subplots(len(Cursors), figsize=(6, len(Cursors) + 0.5), gridspec_kw={'hspace': 0}) diff --git a/examples/widgets/multicursor.py b/examples/widgets/multicursor.py index a8bb8a1e35a4..3a80b9ef8230 100644 --- a/examples/widgets/multicursor.py +++ b/examples/widgets/multicursor.py @@ -10,8 +10,9 @@ shown in all axes. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np + from matplotlib.widgets import MultiCursor t = np.arange(0.0, 2.0, 0.01) diff --git a/examples/widgets/polygon_selector_demo.py b/examples/widgets/polygon_selector_demo.py index f1161c287afc..7efd1429d094 100644 --- a/examples/widgets/polygon_selector_demo.py +++ b/examples/widgets/polygon_selector_demo.py @@ -8,8 +8,8 @@ import numpy as np -from matplotlib.widgets import PolygonSelector from matplotlib.path import Path +from matplotlib.widgets import PolygonSelector class SelectFromCollection: diff --git a/examples/widgets/polygon_selector_simple.py b/examples/widgets/polygon_selector_simple.py index 17fe0d17e60c..8dab957cdca0 100644 --- a/examples/widgets/polygon_selector_simple.py +++ b/examples/widgets/polygon_selector_simple.py @@ -7,6 +7,7 @@ """ import matplotlib.pyplot as plt + from matplotlib.widgets import PolygonSelector # %% diff --git a/examples/widgets/radio_buttons.py b/examples/widgets/radio_buttons.py index 8180ab8b9d42..3fdb25bd4e78 100644 --- a/examples/widgets/radio_buttons.py +++ b/examples/widgets/radio_buttons.py @@ -10,8 +10,9 @@ waves to be shown in the plot. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np + from matplotlib.widgets import RadioButtons t = np.arange(0.0, 2.0, 0.01) diff --git a/examples/widgets/range_slider.py b/examples/widgets/range_slider.py index 6a1c38400acb..1ae40c9841fe 100644 --- a/examples/widgets/range_slider.py +++ b/examples/widgets/range_slider.py @@ -16,8 +16,9 @@ the ``Slider`` snap to discrete values. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np + from matplotlib.widgets import RangeSlider # generate a fake image diff --git a/examples/widgets/rectangle_selector.py b/examples/widgets/rectangle_selector.py index ad03ed76ec6e..4108a8c9c0ea 100644 --- a/examples/widgets/rectangle_selector.py +++ b/examples/widgets/rectangle_selector.py @@ -10,9 +10,10 @@ and release-events. """ -from matplotlib.widgets import EllipseSelector, RectangleSelector -import numpy as np import matplotlib.pyplot as plt +import numpy as np + +from matplotlib.widgets import EllipseSelector, RectangleSelector def select_callback(eclick, erelease): diff --git a/examples/widgets/slider_demo.py b/examples/widgets/slider_demo.py index db7dad8e362e..7dc47b9c7b6f 100644 --- a/examples/widgets/slider_demo.py +++ b/examples/widgets/slider_demo.py @@ -13,9 +13,10 @@ a ``RangeSlider`` to define a range of values. """ -import numpy as np import matplotlib.pyplot as plt -from matplotlib.widgets import Slider, Button +import numpy as np + +from matplotlib.widgets import Button, Slider # The parametrized function to be plotted diff --git a/examples/widgets/slider_snap_demo.py b/examples/widgets/slider_snap_demo.py index 98188c9e6aea..23910415da8f 100644 --- a/examples/widgets/slider_snap_demo.py +++ b/examples/widgets/slider_snap_demo.py @@ -16,9 +16,10 @@ a ``RangeSlider`` to define a range of values. """ -import numpy as np import matplotlib.pyplot as plt -from matplotlib.widgets import Slider, Button +import numpy as np + +from matplotlib.widgets import Button, Slider t = np.arange(0.0, 1.0, 0.001) a0 = 5 diff --git a/examples/widgets/span_selector.py b/examples/widgets/span_selector.py index aea00095ebea..2fe1646948f8 100644 --- a/examples/widgets/span_selector.py +++ b/examples/widgets/span_selector.py @@ -15,8 +15,9 @@ interactivity. You must keep a hard reference to it to prevent this. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np + from matplotlib.widgets import SpanSelector # Fixing random state for reproducibility diff --git a/examples/widgets/textbox.py b/examples/widgets/textbox.py index 1cd926e5f160..de94ba1d3c02 100644 --- a/examples/widgets/textbox.py +++ b/examples/widgets/textbox.py @@ -13,10 +13,10 @@ :doc:`/gallery/text_labels_and_annotations/placing_text_boxes`. """ -import numpy as np import matplotlib.pyplot as plt -from matplotlib.widgets import TextBox +import numpy as np +from matplotlib.widgets import TextBox fig, ax = plt.subplots() fig.subplots_adjust(bottom=0.2) diff --git a/tutorials/advanced/path_tutorial.py b/tutorials/advanced/path_tutorial.py index 3cdddb76c094..82b663be61b6 100644 --- a/tutorials/advanced/path_tutorial.py +++ b/tutorials/advanced/path_tutorial.py @@ -15,8 +15,9 @@ """ import matplotlib.pyplot as plt -from matplotlib.path import Path + import matplotlib.patches as patches +from matplotlib.path import Path verts = [ (0., 0.), # left, bottom @@ -187,6 +188,7 @@ # ax.add_patch(patch) import numpy as np + import matplotlib.patches as patches import matplotlib.path as path diff --git a/tutorials/advanced/patheffects_guide.py b/tutorials/advanced/patheffects_guide.py index 1d89ab6dd6f0..ec396f6842ef 100644 --- a/tutorials/advanced/patheffects_guide.py +++ b/tutorials/advanced/patheffects_guide.py @@ -20,6 +20,7 @@ """ import matplotlib.pyplot as plt + import matplotlib.patheffects as path_effects fig = plt.figure(figsize=(5, 1.5)) diff --git a/tutorials/advanced/transforms_tutorial.py b/tutorials/advanced/transforms_tutorial.py index 9142b8050e89..d254464c2ba8 100644 --- a/tutorials/advanced/transforms_tutorial.py +++ b/tutorials/advanced/transforms_tutorial.py @@ -112,8 +112,9 @@ """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np + import matplotlib.patches as mpatches x = np.arange(0, 10, 0.005) diff --git a/tutorials/colors/colorbar_only.py b/tutorials/colors/colorbar_only.py index a4361fb94e3d..62e786da3e5e 100644 --- a/tutorials/colors/colorbar_only.py +++ b/tutorials/colors/colorbar_only.py @@ -27,6 +27,7 @@ """ import matplotlib.pyplot as plt + import matplotlib as mpl fig, ax = plt.subplots(figsize=(6, 1)) diff --git a/tutorials/colors/colormap-manipulation.py b/tutorials/colors/colormap-manipulation.py index f04162c047b0..432ec892c483 100644 --- a/tutorials/colors/colormap-manipulation.py +++ b/tutorials/colors/colormap-manipulation.py @@ -31,10 +31,11 @@ """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np + import matplotlib as mpl -from matplotlib.colors import ListedColormap, LinearSegmentedColormap +from matplotlib.colors import LinearSegmentedColormap, ListedColormap viridis = mpl.colormaps['viridis'].resampled(8) diff --git a/tutorials/colors/colormapnorms.py b/tutorials/colors/colormapnorms.py index d6fa41c98a1b..d9c20c7910af 100644 --- a/tutorials/colors/colormapnorms.py +++ b/tutorials/colors/colormapnorms.py @@ -41,11 +41,12 @@ can clearly be seen: """ -import numpy as np import matplotlib.pyplot as plt -import matplotlib.colors as colors -import matplotlib.cbook as cbook +import numpy as np + from matplotlib import cm +import matplotlib.cbook as cbook +import matplotlib.colors as colors N = 100 X, Y = np.mgrid[-3:3:complex(0, N), -2:2:complex(0, N)] diff --git a/tutorials/colors/colormaps.py b/tutorials/colors/colormaps.py index 46f89100f818..68f21ee1dd37 100644 --- a/tutorials/colors/colormaps.py +++ b/tutorials/colors/colormaps.py @@ -77,11 +77,12 @@ # sphinx_gallery_thumbnail_number = 2 -import numpy as np -import matplotlib as mpl -import matplotlib.pyplot as plt from colorspacious import cspace_converter +import matplotlib.pyplot as plt +import numpy as np + +import matplotlib as mpl # %% # diff --git a/tutorials/colors/colors.py b/tutorials/colors/colors.py index eb060f09c227..62328743a09d 100644 --- a/tutorials/colors/colors.py +++ b/tutorials/colors/colors.py @@ -95,9 +95,10 @@ """ import matplotlib.pyplot as plt -from matplotlib.patches import Rectangle import numpy as np +from matplotlib.patches import Rectangle + fig, ax = plt.subplots(figsize=(6.5, 1.65), layout='constrained') ax.add_patch(Rectangle((-0.2, -0.35), 11.2, 0.7, color='C1', alpha=0.8)) for i, alpha in enumerate(np.linspace(0, 1, 11)): @@ -130,8 +131,9 @@ # information about controlling colors and style properties. -import numpy as np import matplotlib.pyplot as plt +import numpy as np + import matplotlib as mpl th = np.linspace(0, 2*np.pi, 128) diff --git a/tutorials/intermediate/artists.py b/tutorials/intermediate/artists.py index 91b17105cdcb..9d3b5305b5d4 100644 --- a/tutorials/intermediate/artists.py +++ b/tutorials/intermediate/artists.py @@ -114,8 +114,8 @@ class in the Matplotlib API, and the one you will be working with most """ # sphinx_gallery_capture_repr = ('__repr__',) -import numpy as np import matplotlib.pyplot as plt +import numpy as np fig = plt.figure() fig.subplots_adjust(top=0.8) diff --git a/tutorials/intermediate/autoscale.py b/tutorials/intermediate/autoscale.py index 7bd5667e1769..95a157548804 100644 --- a/tutorials/intermediate/autoscale.py +++ b/tutorials/intermediate/autoscale.py @@ -11,9 +11,10 @@ # We will start with a simple line plot showing that autoscaling # extends the axis limits 5% beyond the data limits (-2π, 2π). +import matplotlib.pyplot as plt import numpy as np + import matplotlib as mpl -import matplotlib.pyplot as plt x = np.linspace(-2 * np.pi, 2 * np.pi, 100) y = np.sinc(x) diff --git a/tutorials/intermediate/color_cycle.py b/tutorials/intermediate/color_cycle.py index fd782ae0e111..e1dc898f6d4c 100644 --- a/tutorials/intermediate/color_cycle.py +++ b/tutorials/intermediate/color_cycle.py @@ -19,8 +19,9 @@ """ from cycler import cycler -import numpy as np + import matplotlib.pyplot as plt +import numpy as np # %% # First we'll generate some sample data, in this case, four offset sine diff --git a/tutorials/intermediate/constrainedlayout_guide.py b/tutorials/intermediate/constrainedlayout_guide.py index 58e44f14fc4f..7f960b27806d 100644 --- a/tutorials/intermediate/constrainedlayout_guide.py +++ b/tutorials/intermediate/constrainedlayout_guide.py @@ -50,9 +50,10 @@ import matplotlib.pyplot as plt +import numpy as np + import matplotlib.colors as mcolors import matplotlib.gridspec as gridspec -import numpy as np plt.rcParams['savefig.facecolor'] = "0.8" plt.rcParams['figure.figsize'] = 4.5, 4. diff --git a/tutorials/intermediate/imshow_extent.py b/tutorials/intermediate/imshow_extent.py index 7de6277958d8..83ef00d5619b 100644 --- a/tutorials/intermediate/imshow_extent.py +++ b/tutorials/intermediate/imshow_extent.py @@ -22,8 +22,9 @@ For a quick understanding, you may want to skip the code details below and directly continue with the discussion of the results. """ -import numpy as np import matplotlib.pyplot as plt +import numpy as np + from matplotlib.gridspec import GridSpec diff --git a/tutorials/intermediate/legend_guide.py b/tutorials/intermediate/legend_guide.py index 9839be18022e..44cafde6757a 100644 --- a/tutorials/intermediate/legend_guide.py +++ b/tutorials/intermediate/legend_guide.py @@ -81,9 +81,10 @@ is represented by a red color: """ -import matplotlib.patches as mpatches import matplotlib.pyplot as plt +import matplotlib.patches as mpatches + fig, ax = plt.subplots() red_patch = mpatches.Patch(color='red', label='The red data') ax.legend(handles=[red_patch]) diff --git a/tutorials/introductory/animation_tutorial.py b/tutorials/introductory/animation_tutorial.py index 53756eb37a94..9b5754fb6e1b 100644 --- a/tutorials/introductory/animation_tutorial.py +++ b/tutorials/introductory/animation_tutorial.py @@ -11,9 +11,10 @@ """ import matplotlib.pyplot as plt -import matplotlib.animation as animation import numpy as np +import matplotlib.animation as animation + # %% # Animation Classes # ================= diff --git a/tutorials/introductory/customizing.py b/tutorials/introductory/customizing.py index 0048e517a63b..4de4246f6eb9 100644 --- a/tutorials/introductory/customizing.py +++ b/tutorials/introductory/customizing.py @@ -29,10 +29,13 @@ rcParams can be modified directly, for example: """ -import numpy as np +from cycler import cycler + import matplotlib.pyplot as plt +import numpy as np + import matplotlib as mpl -from cycler import cycler + mpl.rcParams['lines.linewidth'] = 2 mpl.rcParams['lines.linestyle'] = '--' data = np.random.randn(50) diff --git a/tutorials/introductory/images.py b/tutorials/introductory/images.py index f2d9fbc20191..52b7f502c2de 100644 --- a/tutorials/introductory/images.py +++ b/tutorials/introductory/images.py @@ -48,9 +48,10 @@ """ +from PIL import Image + import matplotlib.pyplot as plt import numpy as np -from PIL import Image # %% # .. _importing_data: diff --git a/tutorials/introductory/lifecycle.py b/tutorials/introductory/lifecycle.py index 1d983302de52..f72197d869bd 100644 --- a/tutorials/introductory/lifecycle.py +++ b/tutorials/introductory/lifecycle.py @@ -54,10 +54,9 @@ """ +import matplotlib.pyplot as plt # sphinx_gallery_thumbnail_number = 10 import numpy as np -import matplotlib.pyplot as plt - data = {'Barton LLC': 109438.50, 'Frami, Hills and Schmidt': 103569.59, diff --git a/tutorials/introductory/pyplot.py b/tutorials/introductory/pyplot.py index 67e3314b8ade..8077e3255bba 100644 --- a/tutorials/introductory/pyplot.py +++ b/tutorials/introductory/pyplot.py @@ -38,6 +38,7 @@ # Generating visualizations with pyplot is very quick: import matplotlib.pyplot as plt + plt.plot([1, 2, 3, 4]) plt.ylabel('some numbers') plt.show() diff --git a/tutorials/introductory/quick_start.py b/tutorials/introductory/quick_start.py index d398b2314187..1ebc6254cf22 100644 --- a/tutorials/introductory/quick_start.py +++ b/tutorials/introductory/quick_start.py @@ -10,11 +10,12 @@ """ -# sphinx_gallery_thumbnail_number = 3 -import matplotlib as mpl import matplotlib.pyplot as plt import numpy as np +# sphinx_gallery_thumbnail_number = 3 +import matplotlib as mpl + # %% # # A simple example diff --git a/tutorials/text/annotations.py b/tutorials/text/annotations.py index 6278f8d41b17..b7a1807f6c33 100644 --- a/tutorials/text/annotations.py +++ b/tutorials/text/annotations.py @@ -32,8 +32,8 @@ # being annotated *xy* and the location of the annotation text *xytext*. Both # of these arguments are ``(x, y)`` tuples: -import numpy as np import matplotlib.pyplot as plt +import numpy as np fig, ax = plt.subplots(figsize=(3, 3)) diff --git a/tutorials/text/text_intro.py b/tutorials/text/text_intro.py index 5200197b25b7..10aae0f40887 100644 --- a/tutorials/text/text_intro.py +++ b/tutorials/text/text_intro.py @@ -66,9 +66,10 @@ """ -import matplotlib import matplotlib.pyplot as plt +import matplotlib + fig = plt.figure() ax = fig.add_subplot() fig.subplots_adjust(top=0.85) diff --git a/tutorials/text/text_props.py b/tutorials/text/text_props.py index 4215e3a48d87..6ac870cab263 100644 --- a/tutorials/text/text_props.py +++ b/tutorials/text/text_props.py @@ -60,6 +60,7 @@ """ import matplotlib.pyplot as plt + import matplotlib.patches as patches # build a rectangle in axes coords