diff --git a/doc/project/history.rst b/doc/project/history.rst index 966b7a3caa38..7f148902898b 100644 --- a/doc/project/history.rst +++ b/doc/project/history.rst @@ -157,7 +157,7 @@ Matplotlib logo (2008 - 2015). def add_math_background(): - ax = fig.add_axes([0., 0., 1., 1.]) + ax = fig.add_axes((0., 0., 1., 1.)) text = [] text.append( @@ -187,7 +187,7 @@ Matplotlib logo (2008 - 2015). def add_polar_bar(): - ax = fig.add_axes([0.025, 0.075, 0.2, 0.85], projection='polar') + ax = fig.add_axes((0.025, 0.075, 0.2, 0.85), projection='polar') ax.patch.set_alpha(axalpha) ax.set_axisbelow(True) diff --git a/doc/users/prev_whats_new/dflt_style_changes.rst b/doc/users/prev_whats_new/dflt_style_changes.rst index a833064b573b..808204383fb8 100644 --- a/doc/users/prev_whats_new/dflt_style_changes.rst +++ b/doc/users/prev_whats_new/dflt_style_changes.rst @@ -1005,7 +1005,7 @@ a cleaner separation between subplots. ax = fig.add_subplot(2, 2, j) ax.hist(np.random.beta(0.5, 0.5, 10000), 25, density=True) - ax.set_xlim([0, 1]) + ax.set_xlim(0, 1) ax.set_title(title) ax = fig.add_subplot(2, 2, j + 2) diff --git a/doc/users/prev_whats_new/whats_new_3.5.0.rst b/doc/users/prev_whats_new/whats_new_3.5.0.rst index e67573702218..fb156d0c68e8 100644 --- a/doc/users/prev_whats_new/whats_new_3.5.0.rst +++ b/doc/users/prev_whats_new/whats_new_3.5.0.rst @@ -274,9 +274,9 @@ of the text inside the Axes of the `.TextBox` widget. fig = plt.figure(figsize=(4, 3)) for i, alignment in enumerate(['left', 'center', 'right']): - box_input = fig.add_axes([0.1, 0.7 - i*0.3, 0.8, 0.2]) - text_box = TextBox(ax=box_input, initial=f'{alignment} alignment', - label='', textalignment=alignment) + box_input = fig.add_axes((0.1, 0.7 - i*0.3, 0.8, 0.2)) + text_box = TextBox(ax=box_input, initial=f'{alignment} alignment', + label='', textalignment=alignment) Simplifying the font setting for usetex mode -------------------------------------------- @@ -375,9 +375,9 @@ attribute. points = ax.scatter((3, 3), (1, 3), (1, 3), c='red', zorder=10, label='zorder=10') - ax.set_xlim((0, 5)) - ax.set_ylim((0, 5)) - ax.set_zlim((0, 2.5)) + ax.set_xlim(0, 5) + ax.set_ylim(0, 5) + ax.set_zlim(0, 2.5) plane = mpatches.Patch(facecolor='white', edgecolor='black', label='zorder=1') @@ -485,7 +485,7 @@ new styling parameters for the added handles. ax = ax_old valmin = 0 valinit = 0.5 - ax.set_xlim([0, 1]) + ax.set_xlim(0, 1) ax_old.axvspan(valmin, valinit, 0, 1) ax.axvline(valinit, 0, 1, color="r", lw=1) ax.set_xticks([]) diff --git a/galleries/examples/animation/rain.py b/galleries/examples/animation/rain.py index 4303e567d074..2a354aaa7c94 100644 --- a/galleries/examples/animation/rain.py +++ b/galleries/examples/animation/rain.py @@ -22,7 +22,7 @@ # Create new Figure and an Axes which fills it. fig = plt.figure(figsize=(7, 7)) -ax = fig.add_axes([0, 0, 1, 1], frameon=False) +ax = fig.add_axes((0, 0, 1, 1), frameon=False) ax.set_xlim(0, 1), ax.set_xticks([]) ax.set_ylim(0, 1), ax.set_yticks([]) diff --git a/galleries/examples/animation/simple_scatter.py b/galleries/examples/animation/simple_scatter.py index 3f8c285810a3..5afef75f6074 100644 --- a/galleries/examples/animation/simple_scatter.py +++ b/galleries/examples/animation/simple_scatter.py @@ -11,7 +11,7 @@ import matplotlib.animation as animation fig, ax = plt.subplots() -ax.set_xlim([0, 10]) +ax.set_xlim(0, 10) scat = ax.scatter(1, 0) x = np.linspace(0, 10) diff --git a/galleries/examples/axes_grid1/make_room_for_ylabel_using_axesgrid.py b/galleries/examples/axes_grid1/make_room_for_ylabel_using_axesgrid.py index f130ef4a6de2..7e914ff76b6b 100644 --- a/galleries/examples/axes_grid1/make_room_for_ylabel_using_axesgrid.py +++ b/galleries/examples/axes_grid1/make_room_for_ylabel_using_axesgrid.py @@ -10,7 +10,7 @@ from mpl_toolkits.axes_grid1.axes_divider import make_axes_area_auto_adjustable fig = plt.figure() -ax = fig.add_axes([0, 0, 1, 1]) +ax = fig.add_axes((0, 0, 1, 1)) ax.set_yticks([0.5], labels=["very long label"]) @@ -19,8 +19,8 @@ # %% fig = plt.figure() -ax1 = fig.add_axes([0, 0, 1, 0.5]) -ax2 = fig.add_axes([0, 0.5, 1, 0.5]) +ax1 = fig.add_axes((0, 0, 1, 0.5)) +ax2 = fig.add_axes((0, 0.5, 1, 0.5)) ax1.set_yticks([0.5], labels=["very long label"]) ax1.set_ylabel("Y label") @@ -33,7 +33,7 @@ # %% fig = plt.figure() -ax1 = fig.add_axes([0, 0, 1, 1]) +ax1 = fig.add_axes((0, 0, 1, 1)) divider = make_axes_locatable(ax1) ax2 = divider.append_axes("right", "100%", pad=0.3, sharey=ax1) diff --git a/galleries/examples/axisartist/demo_parasite_axes.py b/galleries/examples/axisartist/demo_parasite_axes.py index 8565ef455c7e..800b9be32ac8 100644 --- a/galleries/examples/axisartist/demo_parasite_axes.py +++ b/galleries/examples/axisartist/demo_parasite_axes.py @@ -24,7 +24,7 @@ fig = plt.figure() -host = fig.add_axes([0.15, 0.1, 0.65, 0.8], axes_class=HostAxes) +host = fig.add_axes((0.15, 0.1, 0.65, 0.8), axes_class=HostAxes) par1 = host.get_aux_axes(viewlim_mode=None, sharex=host) par2 = host.get_aux_axes(viewlim_mode=None, sharex=host) diff --git a/galleries/examples/event_handling/poly_editor.py b/galleries/examples/event_handling/poly_editor.py index f6efd8bb8446..9cc2e5373ae5 100644 --- a/galleries/examples/event_handling/poly_editor.py +++ b/galleries/examples/event_handling/poly_editor.py @@ -203,6 +203,6 @@ def on_mouse_move(self, event): p = PolygonInteractor(ax, poly) ax.set_title('Click and drag a point to move it') - ax.set_xlim((-2, 2)) - ax.set_ylim((-2, 2)) + ax.set_xlim(-2, 2) + ax.set_ylim(-2, 2) plt.show() diff --git a/galleries/examples/event_handling/pong_sgskip.py b/galleries/examples/event_handling/pong_sgskip.py index 583e51eacdc5..2c4c35a7cb35 100644 --- a/galleries/examples/event_handling/pong_sgskip.py +++ b/galleries/examples/event_handling/pong_sgskip.py @@ -134,9 +134,9 @@ def __init__(self, ax): # create the initial line self.ax = ax ax.xaxis.set_visible(False) - ax.set_xlim([0, 7]) + ax.set_xlim(0, 7) ax.yaxis.set_visible(False) - ax.set_ylim([-1, 1]) + ax.set_ylim(-1, 1) pad_a_x = 0 pad_b_x = .50 pad_a_y = pad_b_y = .30 diff --git a/galleries/examples/images_contours_and_fields/barcode_demo.py b/galleries/examples/images_contours_and_fields/barcode_demo.py index bdf48ca22531..5df58535650d 100644 --- a/galleries/examples/images_contours_and_fields/barcode_demo.py +++ b/galleries/examples/images_contours_and_fields/barcode_demo.py @@ -30,7 +30,7 @@ dpi = 100 fig = plt.figure(figsize=(len(code) * pixel_per_bar / dpi, 2), dpi=dpi) -ax = fig.add_axes([0, 0, 1, 1]) # span the whole figure +ax = fig.add_axes((0, 0, 1, 1)) # span the whole figure ax.set_axis_off() ax.imshow(code.reshape(1, -1), cmap='binary', aspect='auto', interpolation='nearest') diff --git a/galleries/examples/images_contours_and_fields/image_antialiasing.py b/galleries/examples/images_contours_and_fields/image_antialiasing.py index 7f223f6998f2..10f563875767 100644 --- a/galleries/examples/images_contours_and_fields/image_antialiasing.py +++ b/galleries/examples/images_contours_and_fields/image_antialiasing.py @@ -245,7 +245,7 @@ # may serve a 100x100 version of the image, which will be downsampled.) fig = plt.figure(figsize=(2, 2)) -ax = fig.add_axes([0, 0, 1, 1]) +ax = fig.add_axes((0, 0, 1, 1)) ax.imshow(aa[:400, :400], cmap='RdBu_r', interpolation='nearest') plt.show() # %% diff --git a/galleries/examples/images_contours_and_fields/image_exact_placement.py b/galleries/examples/images_contours_and_fields/image_exact_placement.py index a3b314a7c7c3..7c667dfed1af 100644 --- a/galleries/examples/images_contours_and_fields/image_exact_placement.py +++ b/galleries/examples/images_contours_and_fields/image_exact_placement.py @@ -134,13 +134,13 @@ def annotate_rect(ax): fig = plt.figure(figsize=(fig_width / dpi, fig_height / dpi), facecolor='aliceblue') # the position posA must be normalized by the figure width and height: -ax = fig.add_axes([posA[0] / fig_width, posA[1] / fig_height, - posA[2] / fig_width, posA[3] / fig_height]) +ax = fig.add_axes((posA[0] / fig_width, posA[1] / fig_height, + posA[2] / fig_width, posA[3] / fig_height)) ax.imshow(A, vmin=-1, vmax=1) annotate_rect(ax) -ax = fig.add_axes([posB[0] / fig_width, posB[1] / fig_height, - posB[2] / fig_width, posB[3] / fig_height]) +ax = fig.add_axes((posB[0] / fig_width, posB[1] / fig_height, + posB[2] / fig_width, posB[3] / fig_height)) ax.imshow(B, vmin=-1, vmax=1) plt.show() # %% diff --git a/galleries/examples/lines_bars_and_markers/eventcollection_demo.py b/galleries/examples/lines_bars_and_markers/eventcollection_demo.py index 1aa2fa622812..6854a13e0974 100644 --- a/galleries/examples/lines_bars_and_markers/eventcollection_demo.py +++ b/galleries/examples/lines_bars_and_markers/eventcollection_demo.py @@ -53,8 +53,8 @@ ax.add_collection(yevents2) # set the limits -ax.set_xlim([0, 1]) -ax.set_ylim([0, 1]) +ax.set_xlim(0, 1) +ax.set_ylim(0, 1) ax.set_title('line plot with data points') diff --git a/galleries/examples/lines_bars_and_markers/markevery_demo.py b/galleries/examples/lines_bars_and_markers/markevery_demo.py index 919e12cde952..da4da0ecf9f1 100644 --- a/galleries/examples/lines_bars_and_markers/markevery_demo.py +++ b/galleries/examples/lines_bars_and_markers/markevery_demo.py @@ -79,8 +79,8 @@ for ax, markevery in zip(axs.flat, cases): ax.set_title(f'markevery={markevery}') ax.plot(x, y, 'o', ls='-', ms=4, markevery=markevery) - ax.set_xlim((6, 6.7)) - ax.set_ylim((1.1, 1.7)) + ax.set_xlim(6, 6.7) + ax.set_ylim(1.1, 1.7) # %% # markevery on polar plots diff --git a/galleries/examples/misc/svg_filter_line.py b/galleries/examples/misc/svg_filter_line.py index c6adec093bee..dd97dc975eda 100644 --- a/galleries/examples/misc/svg_filter_line.py +++ b/galleries/examples/misc/svg_filter_line.py @@ -17,7 +17,7 @@ import matplotlib.transforms as mtransforms fig1 = plt.figure() -ax = fig1.add_axes([0.1, 0.1, 0.8, 0.8]) +ax = fig1.add_axes((0.1, 0.1, 0.8, 0.8)) # draw lines l1, = ax.plot([0.1, 0.5, 0.9], [0.1, 0.9, 0.5], "bo-", diff --git a/galleries/examples/misc/svg_filter_pie.py b/galleries/examples/misc/svg_filter_pie.py index b823cc9670c9..b19867be9a2f 100644 --- a/galleries/examples/misc/svg_filter_pie.py +++ b/galleries/examples/misc/svg_filter_pie.py @@ -19,7 +19,7 @@ # make a square figure and Axes fig = plt.figure(figsize=(6, 6)) -ax = fig.add_axes([0.1, 0.1, 0.8, 0.8]) +ax = fig.add_axes((0.1, 0.1, 0.8, 0.8)) labels = 'Frogs', 'Hogs', 'Dogs', 'Logs' fracs = [15, 30, 45, 10] diff --git a/galleries/examples/mplot3d/box3d.py b/galleries/examples/mplot3d/box3d.py index 807e3d496ec6..4d75c8bc2809 100644 --- a/galleries/examples/mplot3d/box3d.py +++ b/galleries/examples/mplot3d/box3d.py @@ -51,7 +51,7 @@ xmin, xmax = X.min(), X.max() ymin, ymax = Y.min(), Y.max() zmin, zmax = Z.min(), Z.max() -ax.set(xlim=[xmin, xmax], ylim=[ymin, ymax], zlim=[zmin, zmax]) +ax.set(xlim=(xmin, xmax), ylim=(ymin, ymax), zlim=(zmin, zmax)) # Plot edges edges_kw = dict(color='0.4', linewidth=1, zorder=1e3) diff --git a/galleries/examples/shapes_and_collections/hatch_demo.py b/galleries/examples/shapes_and_collections/hatch_demo.py index f2ca490c4e37..8d44dba5489b 100644 --- a/galleries/examples/shapes_and_collections/hatch_demo.py +++ b/galleries/examples/shapes_and_collections/hatch_demo.py @@ -41,8 +41,8 @@ hatch='*', facecolor='y')) axs['patches'].add_patch(Polygon([(10, 20), (30, 50), (50, 10)], hatch='\\/...', facecolor='g')) -axs['patches'].set_xlim([0, 40]) -axs['patches'].set_ylim([10, 60]) +axs['patches'].set_xlim(0, 40) +axs['patches'].set_ylim(10, 60) axs['patches'].set_aspect(1) plt.show() diff --git a/galleries/examples/showcase/anatomy.py b/galleries/examples/showcase/anatomy.py index b1fbde9c8d7b..798e4204cad3 100644 --- a/galleries/examples/showcase/anatomy.py +++ b/galleries/examples/showcase/anatomy.py @@ -27,7 +27,7 @@ Y3 = np.random.uniform(Y1, Y2, len(X)) fig = plt.figure(figsize=(7.5, 7.5)) -ax = fig.add_axes([0.2, 0.17, 0.68, 0.7], aspect=1) +ax = fig.add_axes((0.2, 0.17, 0.68, 0.7), aspect=1) ax.xaxis.set_major_locator(MultipleLocator(1.000)) ax.xaxis.set_minor_locator(AutoMinorLocator(4)) diff --git a/galleries/examples/showcase/firefox.py b/galleries/examples/showcase/firefox.py index 65682ccd7429..2026d253f6b6 100644 --- a/galleries/examples/showcase/firefox.py +++ b/galleries/examples/showcase/firefox.py @@ -48,7 +48,7 @@ def svg_parse(path): xmax, ymax = verts.max(axis=0) + 1 fig = plt.figure(figsize=(5, 5), facecolor="0.75") # gray background -ax = fig.add_axes([0, 0, 1, 1], frameon=False, aspect=1, +ax = fig.add_axes((0, 0, 1, 1), frameon=False, aspect=1, xlim=(xmin, xmax), # centering ylim=(ymax, ymin), # centering, upside down xticks=[], yticks=[]) # no ticks diff --git a/galleries/examples/showcase/mandelbrot.py b/galleries/examples/showcase/mandelbrot.py index ab40a061dc03..d8b7faf4c7b8 100644 --- a/galleries/examples/showcase/mandelbrot.py +++ b/galleries/examples/showcase/mandelbrot.py @@ -55,7 +55,7 @@ def mandelbrot_set(xmin, xmax, ymin, ymax, xn, yn, maxiter, horizon=2.0): width = 10 height = 10*yn/xn fig = plt.figure(figsize=(width, height), dpi=dpi) - ax = fig.add_axes([0, 0, 1, 1], frameon=False, aspect=1) + ax = fig.add_axes((0, 0, 1, 1), frameon=False, aspect=1) # Shaded rendering light = colors.LightSource(azdeg=315, altdeg=10) diff --git a/galleries/examples/showcase/xkcd.py b/galleries/examples/showcase/xkcd.py index 3d6d5418a13f..9b4de0a90f5b 100644 --- a/galleries/examples/showcase/xkcd.py +++ b/galleries/examples/showcase/xkcd.py @@ -19,7 +19,7 @@ ax.spines[['top', 'right']].set_visible(False) ax.set_xticks([]) ax.set_yticks([]) - ax.set_ylim([-30, 10]) + ax.set_ylim(-30, 10) data = np.ones(100) data[70:] -= np.arange(30) @@ -50,9 +50,9 @@ ax.xaxis.set_ticks_position('bottom') ax.set_xticks([0, 1]) ax.set_xticklabels(['CONFIRMED BY\nEXPERIMENT', 'REFUTED BY\nEXPERIMENT']) - ax.set_xlim([-0.5, 1.5]) + ax.set_xlim(-0.5, 1.5) ax.set_yticks([]) - ax.set_ylim([0, 110]) + ax.set_ylim(0, 110) ax.set_title("CLAIMS OF SUPERNATURAL POWERS") diff --git a/galleries/examples/specialty_plots/leftventricle_bullseye.py b/galleries/examples/specialty_plots/leftventricle_bullseye.py index 3ad02edbc630..285fcdaecc5e 100644 --- a/galleries/examples/specialty_plots/leftventricle_bullseye.py +++ b/galleries/examples/specialty_plots/leftventricle_bullseye.py @@ -55,7 +55,7 @@ def bullseye_plot(ax, data, seg_bold=None, cmap="viridis", norm=None): r = np.linspace(0.2, 1, 4) - ax.set(ylim=[0, 1], xticklabels=[], yticklabels=[]) + ax.set(ylim=(0, 1), xticklabels=[], yticklabels=[]) ax.grid(False) # Remove grid # Fill segments 1-6, 7-12, 13-16. diff --git a/galleries/examples/statistics/errorbar_limits.py b/galleries/examples/statistics/errorbar_limits.py index f1d26460d947..fde18327af83 100644 --- a/galleries/examples/statistics/errorbar_limits.py +++ b/galleries/examples/statistics/errorbar_limits.py @@ -71,7 +71,7 @@ linestyle='none') # tidy up the figure -ax.set_xlim((0, 5.5)) +ax.set_xlim(0, 5.5) ax.set_title('Errorbar upper and lower limits') plt.show() diff --git a/galleries/examples/subplots_axes_and_figures/axes_demo.py b/galleries/examples/subplots_axes_and_figures/axes_demo.py index 07f3ca2070c2..16db465449a4 100644 --- a/galleries/examples/subplots_axes_and_figures/axes_demo.py +++ b/galleries/examples/subplots_axes_and_figures/axes_demo.py @@ -33,12 +33,12 @@ main_ax.set_title('Gaussian colored noise') # this is an inset Axes over the main Axes -right_inset_ax = fig.add_axes([.65, .6, .2, .2], facecolor='k') +right_inset_ax = fig.add_axes((.65, .6, .2, .2), facecolor='k') right_inset_ax.hist(s, 400, density=True) right_inset_ax.set(title='Probability', xticks=[], yticks=[]) # this is another inset Axes over the main Axes -left_inset_ax = fig.add_axes([.2, .6, .2, .2], facecolor='k') +left_inset_ax = fig.add_axes((.2, .6, .2, .2), facecolor='k') left_inset_ax.plot(t[:len(r)], r) left_inset_ax.set(title='Impulse response', xlim=(0, .2), xticks=[], yticks=[]) diff --git a/galleries/examples/text_labels_and_annotations/mathtext_examples.py b/galleries/examples/text_labels_and_annotations/mathtext_examples.py index f9f8e628e08b..cf395f0daf0e 100644 --- a/galleries/examples/text_labels_and_annotations/mathtext_examples.py +++ b/galleries/examples/text_labels_and_annotations/mathtext_examples.py @@ -61,7 +61,7 @@ def doall(): # Creating figure and axis. fig = plt.figure(figsize=(7, 7)) - ax = fig.add_axes([0.01, 0.01, 0.98, 0.90], + ax = fig.add_axes((0.01, 0.01, 0.98, 0.90), facecolor="white", frameon=True) ax.set_xlim(0, 1) ax.set_ylim(0, 1) diff --git a/galleries/examples/ticks/fig_axes_customize_simple.py b/galleries/examples/ticks/fig_axes_customize_simple.py index 0dd85ec4bd93..07a569e3d31d 100644 --- a/galleries/examples/ticks/fig_axes_customize_simple.py +++ b/galleries/examples/ticks/fig_axes_customize_simple.py @@ -13,7 +13,7 @@ fig = plt.figure() fig.patch.set_facecolor('lightgoldenrodyellow') -ax1 = fig.add_axes([0.1, 0.3, 0.4, 0.4]) +ax1 = fig.add_axes((0.1, 0.3, 0.4, 0.4)) ax1.patch.set_facecolor('lightslategray') ax1.tick_params(axis='x', labelcolor='tab:red', labelrotation=45, labelsize=16) diff --git a/galleries/examples/user_interfaces/fourier_demo_wx_sgskip.py b/galleries/examples/user_interfaces/fourier_demo_wx_sgskip.py index f51917fda6b9..9e72b3745a40 100644 --- a/galleries/examples/user_interfaces/fourier_demo_wx_sgskip.py +++ b/galleries/examples/user_interfaces/fourier_demo_wx_sgskip.py @@ -194,10 +194,10 @@ def createPlots(self): self.subplot1.set_xlabel("frequency f", fontsize=8) self.subplot2.set_ylabel("Time Domain Waveform x(t)", fontsize=8) self.subplot2.set_xlabel("time t", fontsize=8) - self.subplot1.set_xlim([-6, 6]) - self.subplot1.set_ylim([0, 1]) - self.subplot2.set_xlim([-2, 2]) - self.subplot2.set_ylim([-2, 2]) + self.subplot1.set_xlim(-6, 6) + self.subplot1.set_ylim(0, 1) + self.subplot2.set_xlim(-2, 2) + self.subplot2.set_ylim(-2, 2) self.subplot1.text(0.05, .95, r'$X(f) = \mathcal{F}\{x(t)\}$', verticalalignment='top', diff --git a/galleries/examples/widgets/buttons.py b/galleries/examples/widgets/buttons.py index 61249522c72c..2aef798399f4 100644 --- a/galleries/examples/widgets/buttons.py +++ b/galleries/examples/widgets/buttons.py @@ -41,8 +41,8 @@ def prev(self, event): plt.draw() callback = Index() -axprev = fig.add_axes([0.7, 0.05, 0.1, 0.075]) -axnext = fig.add_axes([0.81, 0.05, 0.1, 0.075]) +axprev = fig.add_axes((0.7, 0.05, 0.1, 0.075)) +axnext = fig.add_axes((0.81, 0.05, 0.1, 0.075)) bnext = Button(axnext, 'Next') bnext.on_clicked(callback.next) bprev = Button(axprev, 'Previous') diff --git a/galleries/examples/widgets/range_slider.py b/galleries/examples/widgets/range_slider.py index f1bed7431e39..d2f2d1554246 100644 --- a/galleries/examples/widgets/range_slider.py +++ b/galleries/examples/widgets/range_slider.py @@ -34,7 +34,7 @@ axs[1].set_title('Histogram of pixel intensities') # Create the RangeSlider -slider_ax = fig.add_axes([0.20, 0.1, 0.60, 0.03]) +slider_ax = fig.add_axes((0.20, 0.1, 0.60, 0.03)) slider = RangeSlider(slider_ax, "Threshold", img.min(), img.max()) # Create the Vertical lines on the histogram diff --git a/galleries/examples/widgets/slider_demo.py b/galleries/examples/widgets/slider_demo.py index 7dc47b9c7b6f..e56390c182a0 100644 --- a/galleries/examples/widgets/slider_demo.py +++ b/galleries/examples/widgets/slider_demo.py @@ -38,7 +38,7 @@ def f(t, amplitude, frequency): fig.subplots_adjust(left=0.25, bottom=0.25) # Make a horizontal slider to control the frequency. -axfreq = fig.add_axes([0.25, 0.1, 0.65, 0.03]) +axfreq = fig.add_axes((0.25, 0.1, 0.65, 0.03)) freq_slider = Slider( ax=axfreq, label='Frequency [Hz]', @@ -48,7 +48,7 @@ def f(t, amplitude, frequency): ) # Make a vertically oriented slider to control the amplitude -axamp = fig.add_axes([0.1, 0.25, 0.0225, 0.63]) +axamp = fig.add_axes((0.1, 0.25, 0.0225, 0.63)) amp_slider = Slider( ax=axamp, label="Amplitude", @@ -70,7 +70,7 @@ def update(val): amp_slider.on_changed(update) # Create a `matplotlib.widgets.Button` to reset the sliders to initial values. -resetax = fig.add_axes([0.8, 0.025, 0.1, 0.04]) +resetax = fig.add_axes((0.8, 0.025, 0.1, 0.04)) button = Button(resetax, 'Reset', hovercolor='0.975') diff --git a/galleries/examples/widgets/slider_snap_demo.py b/galleries/examples/widgets/slider_snap_demo.py index 953ffaf63672..5826be32fa07 100644 --- a/galleries/examples/widgets/slider_snap_demo.py +++ b/galleries/examples/widgets/slider_snap_demo.py @@ -30,8 +30,8 @@ fig.subplots_adjust(bottom=0.25) l, = ax.plot(t, s, lw=2) -ax_freq = fig.add_axes([0.25, 0.1, 0.65, 0.03]) -ax_amp = fig.add_axes([0.25, 0.15, 0.65, 0.03]) +ax_freq = fig.add_axes((0.25, 0.1, 0.65, 0.03)) +ax_amp = fig.add_axes((0.25, 0.15, 0.65, 0.03)) # define the values to use for snapping allowed_amplitudes = np.concatenate([np.linspace(.1, 5, 100), [6, 7, 8, 9]]) @@ -60,7 +60,7 @@ def update(val): sfreq.on_changed(update) samp.on_changed(update) -ax_reset = fig.add_axes([0.8, 0.025, 0.1, 0.04]) +ax_reset = fig.add_axes((0.8, 0.025, 0.1, 0.04)) button = Button(ax_reset, 'Reset', hovercolor='0.975') diff --git a/galleries/examples/widgets/textbox.py b/galleries/examples/widgets/textbox.py index d5f02b82a30b..2121ce8594ce 100644 --- a/galleries/examples/widgets/textbox.py +++ b/galleries/examples/widgets/textbox.py @@ -39,7 +39,7 @@ def submit(expression): plt.draw() -axbox = fig.add_axes([0.1, 0.05, 0.8, 0.075]) +axbox = fig.add_axes((0.1, 0.05, 0.8, 0.075)) text_box = TextBox(axbox, "Evaluate", textalignment="center") text_box.on_submit(submit) text_box.set_val("t ** 2") # Trigger `submit` with the initial string. diff --git a/galleries/tutorials/artists.py b/galleries/tutorials/artists.py index a258eb71d447..4f93f7c71a6e 100644 --- a/galleries/tutorials/artists.py +++ b/galleries/tutorials/artists.py @@ -70,7 +70,7 @@ class in the Matplotlib API, and the one you will be working with most coordinates:: fig2 = plt.figure() - ax2 = fig2.add_axes([0.15, 0.1, 0.7, 0.3]) + ax2 = fig2.add_axes((0.15, 0.1, 0.7, 0.3)) Continuing with our example:: @@ -134,7 +134,7 @@ class in the Matplotlib API, and the one you will be working with most # Fixing random state for reproducibility np.random.seed(19680801) -ax2 = fig.add_axes([0.15, 0.1, 0.7, 0.3]) +ax2 = fig.add_axes((0.15, 0.1, 0.7, 0.3)) n, bins, patches = ax2.hist(np.random.randn(1000), 50, facecolor='yellow', edgecolor='yellow') ax2.set_xlabel('Time [s]') @@ -295,7 +295,7 @@ class in the Matplotlib API, and the one you will be working with most # # In [157]: ax1 = fig.add_subplot(211) # -# In [158]: ax2 = fig.add_axes([0.1, 0.1, 0.7, 0.3]) +# In [158]: ax2 = fig.add_axes((0.1, 0.1, 0.7, 0.3)) # # In [159]: ax1 # Out[159]: @@ -669,7 +669,7 @@ class in the Matplotlib API, and the one you will be working with most rect = fig.patch # a rectangle instance rect.set_facecolor('lightgoldenrodyellow') -ax1 = fig.add_axes([0.1, 0.3, 0.4, 0.4]) +ax1 = fig.add_axes((0.1, 0.3, 0.4, 0.4)) rect = ax1.patch rect.set_facecolor('lightslategray') diff --git a/galleries/tutorials/lifecycle.py b/galleries/tutorials/lifecycle.py index 4aae4d6c1dbc..4c009f802cf4 100644 --- a/galleries/tutorials/lifecycle.py +++ b/galleries/tutorials/lifecycle.py @@ -169,7 +169,7 @@ ax.barh(group_names, group_data) labels = ax.get_xticklabels() plt.setp(labels, rotation=45, horizontalalignment='right') -ax.set(xlim=[-10000, 140000], xlabel='Total Revenue', ylabel='Company', +ax.set(xlim=(-10000, 140000), xlabel='Total Revenue', ylabel='Company', title='Company Revenue') # %% @@ -187,7 +187,7 @@ ax.barh(group_names, group_data) labels = ax.get_xticklabels() plt.setp(labels, rotation=45, horizontalalignment='right') -ax.set(xlim=[-10000, 140000], xlabel='Total Revenue', ylabel='Company', +ax.set(xlim=(-10000, 140000), xlabel='Total Revenue', ylabel='Company', title='Company Revenue') # %% @@ -220,7 +220,7 @@ def currency(x, pos): labels = ax.get_xticklabels() plt.setp(labels, rotation=45, horizontalalignment='right') -ax.set(xlim=[-10000, 140000], xlabel='Total Revenue', ylabel='Company', +ax.set(xlim=(-10000, 140000), xlabel='Total Revenue', ylabel='Company', title='Company Revenue') ax.xaxis.set_major_formatter(currency) @@ -248,7 +248,7 @@ def currency(x, pos): # Now we move our title up since it's getting a little cramped ax.title.set(y=1.05) -ax.set(xlim=[-10000, 140000], xlabel='Total Revenue', ylabel='Company', +ax.set(xlim=(-10000, 140000), xlabel='Total Revenue', ylabel='Company', title='Company Revenue') ax.xaxis.set_major_formatter(currency) ax.set_xticks([0, 25e3, 50e3, 75e3, 100e3, 125e3]) diff --git a/galleries/users_explain/animations/animations.py b/galleries/users_explain/animations/animations.py index a0669956ab81..dca49fc5228e 100644 --- a/galleries/users_explain/animations/animations.py +++ b/galleries/users_explain/animations/animations.py @@ -111,7 +111,7 @@ scat = ax.scatter(t[0], z[0], c="b", s=5, label=f'v0 = {v0} m/s') line2 = ax.plot(t[0], z2[0], label=f'v0 = {v02} m/s')[0] -ax.set(xlim=[0, 3], ylim=[-4, 10], xlabel='Time [s]', ylabel='Z [m]') +ax.set(xlim=(0, 3), ylim=(-4, 10), xlabel='Time [s]', ylabel='Z [m]') ax.legend() diff --git a/galleries/users_explain/artists/transforms_tutorial.py b/galleries/users_explain/artists/transforms_tutorial.py index f8a3e98e8077..3920fe886c7f 100644 --- a/galleries/users_explain/artists/transforms_tutorial.py +++ b/galleries/users_explain/artists/transforms_tutorial.py @@ -401,7 +401,7 @@ fig, ax = plt.subplots() xdata, ydata = (0.2, 0.7), (0.5, 0.5) ax.plot(xdata, ydata, "o") -ax.set_xlim((0, 1)) +ax.set_xlim(0, 1) trans = (fig.dpi_scale_trans + transforms.ScaledTranslation(xdata[0], ydata[0], ax.transData)) diff --git a/galleries/users_explain/axes/arranging_axes.py b/galleries/users_explain/axes/arranging_axes.py index bc537e15c12c..64879d4a696d 100644 --- a/galleries/users_explain/axes/arranging_axes.py +++ b/galleries/users_explain/axes/arranging_axes.py @@ -103,8 +103,8 @@ w, h = 4, 3 margin = 0.5 fig = plt.figure(figsize=(w, h), facecolor='lightblue') -ax = fig.add_axes([margin / w, margin / h, (w - 2 * margin) / w, - (h - 2 * margin) / h]) +ax = fig.add_axes((margin / w, margin / h, + (w - 2 * margin) / w, (h - 2 * margin) / h)) # %% diff --git a/galleries/users_explain/axes/axes_intro.rst b/galleries/users_explain/axes/axes_intro.rst index 16738d929056..bb3094495026 100644 --- a/galleries/users_explain/axes/axes_intro.rst +++ b/galleries/users_explain/axes/axes_intro.rst @@ -52,8 +52,8 @@ Axes are added using methods on `~.Figure` objects, or via the `~.pyplot` interf There are a number of other methods for adding Axes to a Figure: -* `.Figure.add_axes`: manually position an Axes. ``fig.add_axes([0, 0, 1, - 1])`` makes an Axes that fills the whole figure. +* `.Figure.add_axes`: manually position an Axes. ``fig.add_axes((0, 0, 1, 1))`` makes an + Axes that fills the whole figure. * `.pyplot.subplots` and `.Figure.subplots`: add a grid of Axes as in the example above. The pyplot version returns both the Figure object and an array of Axes. Note that ``fig, ax = plt.subplots()`` adds a single Axes to a Figure. @@ -143,7 +143,7 @@ Other important methods set the extent on the axes (`~.axes.Axes.set_xlim`, `~.a x = 2**np.cumsum(np.random.randn(200)) linesx = ax.plot(t, x) ax.set_yscale('log') - ax.set_xlim([20, 180]) + ax.set_xlim(20, 180) The Axes class also has helpers to deal with Axis ticks and their labels. Most straight-forward is `~.axes.Axes.set_xticks` and `~.axes.Axes.set_yticks` which manually set the tick locations and optionally their labels. Minor ticks can be toggled with `~.axes.Axes.minorticks_on` or `~.axes.Axes.minorticks_off`. diff --git a/galleries/users_explain/axes/axes_scales.py b/galleries/users_explain/axes/axes_scales.py index 6b163835070c..f901c012974a 100644 --- a/galleries/users_explain/axes/axes_scales.py +++ b/galleries/users_explain/axes/axes_scales.py @@ -171,7 +171,7 @@ def inverse(a): ax.set_yscale('function', functions=(forward, inverse)) ax.set_title('function: Mercator') ax.grid(True) -ax.set_xlim([0, 180]) +ax.set_xlim(0, 180) ax.yaxis.set_minor_formatter(NullFormatter()) ax.yaxis.set_major_locator(FixedLocator(np.arange(0, 90, 10))) diff --git a/galleries/users_explain/colors/colors.py b/galleries/users_explain/colors/colors.py index c91a5fcb0dbe..97a281bf1977 100644 --- a/galleries/users_explain/colors/colors.py +++ b/galleries/users_explain/colors/colors.py @@ -197,7 +197,7 @@ def demo(sty): if f'xkcd:{name}' in mcolors.XKCD_COLORS} fig = plt.figure(figsize=[9, 5]) -ax = fig.add_axes([0, 0, 1, 1]) +ax = fig.add_axes((0, 0, 1, 1)) n_groups = 3 n_rows = len(overlap) // n_groups + 1 diff --git a/galleries/users_explain/text/text_props.py b/galleries/users_explain/text/text_props.py index c5ae22c02d38..fb67421fd880 100644 --- a/galleries/users_explain/text/text_props.py +++ b/galleries/users_explain/text/text_props.py @@ -75,7 +75,7 @@ top = bottom + height fig = plt.figure() -ax = fig.add_axes([0, 0, 1, 1]) +ax = fig.add_axes((0, 0, 1, 1)) # axes coordinates: (0, 0) is bottom left and (1, 1) is upper right p = patches.Rectangle( diff --git a/galleries/users_explain/toolkits/axisartist.rst b/galleries/users_explain/toolkits/axisartist.rst index eff2b575a63f..7ff0897f23d8 100644 --- a/galleries/users_explain/toolkits/axisartist.rst +++ b/galleries/users_explain/toolkits/axisartist.rst @@ -50,7 +50,7 @@ To create an Axes, :: import mpl_toolkits.axisartist as AA fig = plt.figure() - fig.add_axes([0.1, 0.1, 0.8, 0.8], axes_class=AA.Axes) + fig.add_axes((0.1, 0.1, 0.8, 0.8), axes_class=AA.Axes) or to create a subplot :: diff --git a/lib/matplotlib/_enums.py b/lib/matplotlib/_enums.py index 75a09b7b5d8c..d85c5c5f03db 100644 --- a/lib/matplotlib/_enums.py +++ b/lib/matplotlib/_enums.py @@ -151,7 +151,7 @@ def demo(): import matplotlib.pyplot as plt fig = plt.figure(figsize=(4, 1.2)) - ax = fig.add_axes([0, 0, 1, 0.8]) + ax = fig.add_axes((0, 0, 1, 0.8)) ax.set_title('Cap style') for x, style in enumerate(['butt', 'round', 'projecting']): diff --git a/lib/matplotlib/axes/_base.py b/lib/matplotlib/axes/_base.py index c5c525b29a06..987ffc8defa5 100644 --- a/lib/matplotlib/axes/_base.py +++ b/lib/matplotlib/axes/_base.py @@ -2179,9 +2179,9 @@ def axis(self, arg=None, /, *, emit=True, **kwargs): xlim = self.get_xlim() ylim = self.get_ylim() edge_size = max(np.diff(xlim), np.diff(ylim))[0] - self.set_xlim([xlim[0], xlim[0] + edge_size], + self.set_xlim(xlim[0], xlim[0] + edge_size, emit=emit, auto=False) - self.set_ylim([ylim[0], ylim[0] + edge_size], + self.set_ylim(ylim[0], ylim[0] + edge_size, emit=emit, auto=False) else: raise ValueError(f"Unrecognized string {arg!r} to axis; " diff --git a/lib/matplotlib/figure.py b/lib/matplotlib/figure.py index ec11e379db60..01ddd6c2bac5 100644 --- a/lib/matplotlib/figure.py +++ b/lib/matplotlib/figure.py @@ -3678,7 +3678,7 @@ def figaspect(arg): w, h = figaspect(2.) fig = Figure(figsize=(w, h)) - ax = fig.add_axes([0.1, 0.1, 0.8, 0.8]) + ax = fig.add_axes((0.1, 0.1, 0.8, 0.8)) ax.imshow(A, **kwargs) Make a figure with the proper aspect for an array:: @@ -3686,7 +3686,7 @@ def figaspect(arg): A = rand(5, 3) w, h = figaspect(A) fig = Figure(figsize=(w, h)) - ax = fig.add_axes([0.1, 0.1, 0.8, 0.8]) + ax = fig.add_axes((0.1, 0.1, 0.8, 0.8)) ax.imshow(A, **kwargs) """ diff --git a/lib/matplotlib/image.py b/lib/matplotlib/image.py index 760235b6284d..afb75d042c6d 100644 --- a/lib/matplotlib/image.py +++ b/lib/matplotlib/image.py @@ -967,9 +967,9 @@ def set_extent(self, extent, **kwargs): self.sticky_edges.x[:] = [xmin, xmax] self.sticky_edges.y[:] = [ymin, ymax] if self.axes.get_autoscalex_on(): - self.axes.set_xlim((xmin, xmax), auto=None) + self.axes.set_xlim(xmin, xmax, auto=None) if self.axes.get_autoscaley_on(): - self.axes.set_ylim((ymin, ymax), auto=None) + self.axes.set_ylim(ymin, ymax, auto=None) self.stale = True def get_extent(self): @@ -1772,7 +1772,7 @@ def thumbnail(infile, thumbfile, scale=0.1, interpolation='bilinear', fig = Figure(figsize=(width, height), dpi=dpi) FigureCanvasBase(fig) - ax = fig.add_axes([0, 0, 1, 1], aspect='auto', + ax = fig.add_axes((0, 0, 1, 1), aspect='auto', frameon=False, xticks=[], yticks=[]) ax.imshow(im, aspect='auto', resample=True, interpolation=interpolation) fig.savefig(thumbfile, dpi=dpi) diff --git a/lib/matplotlib/tests/test_arrow_patches.py b/lib/matplotlib/tests/test_arrow_patches.py index c2b6d4fa8086..e26c806c9ea4 100644 --- a/lib/matplotlib/tests/test_arrow_patches.py +++ b/lib/matplotlib/tests/test_arrow_patches.py @@ -59,8 +59,8 @@ def __prepare_fancyarrow_dpi_cor_test(): """ fig2 = plt.figure("fancyarrow_dpi_cor_test", figsize=(4, 3), dpi=50) ax = fig2.add_subplot() - ax.set_xlim([0, 1]) - ax.set_ylim([0, 1]) + ax.set_xlim(0, 1) + ax.set_ylim(0, 1) ax.add_patch(mpatches.FancyArrowPatch(posA=(0.3, 0.4), posB=(0.8, 0.6), lw=3, arrowstyle='->', mutation_scale=100)) diff --git a/lib/matplotlib/tests/test_artist.py b/lib/matplotlib/tests/test_artist.py index 5c8141e40741..1367701ffe3e 100644 --- a/lib/matplotlib/tests/test_artist.py +++ b/lib/matplotlib/tests/test_artist.py @@ -120,15 +120,15 @@ def test_clipping(): patch.set_clip_path(clip_path, ax2.transData) ax2.add_patch(patch) - ax1.set_xlim([-3, 3]) - ax1.set_ylim([-3, 3]) + ax1.set_xlim(-3, 3) + ax1.set_ylim(-3, 3) @check_figures_equal() def test_clipping_zoom(fig_test, fig_ref): # This test places the Axes and sets its limits such that the clip path is # outside the figure entirely. This should not break the clip path. - ax_test = fig_test.add_axes([0, 0, 1, 1]) + ax_test = fig_test.add_axes((0, 0, 1, 1)) l, = ax_test.plot([-3, 3], [-3, 3]) # Explicit Path instead of a Rectangle uses clip path processing, instead # of a clip box optimization. @@ -136,7 +136,7 @@ def test_clipping_zoom(fig_test, fig_ref): p = mpatches.PathPatch(p, transform=ax_test.transData) l.set_clip_path(p) - ax_ref = fig_ref.add_axes([0, 0, 1, 1]) + ax_ref = fig_ref.add_axes((0, 0, 1, 1)) ax_ref.plot([-3, 3], [-3, 3]) ax_ref.set(xlim=(0.5, 0.75), ylim=(0.5, 0.75)) @@ -226,8 +226,8 @@ def test_default_edges(): np.arange(10) + 1, np.arange(10), 'o') ax2.bar(np.arange(10), np.arange(10), align='edge') ax3.text(0, 0, "BOX", size=24, bbox=dict(boxstyle='sawtooth')) - ax3.set_xlim((-1, 1)) - ax3.set_ylim((-1, 1)) + ax3.set_xlim(-1, 1) + ax3.set_ylim(-1, 1) pp1 = mpatches.PathPatch( mpath.Path([(0, 0), (1, 0), (1, 1), (0, 0)], [mpath.Path.MOVETO, mpath.Path.CURVE3, diff --git a/lib/matplotlib/tests/test_axes.py b/lib/matplotlib/tests/test_axes.py index c1758d2ec3e0..50e214b15225 100644 --- a/lib/matplotlib/tests/test_axes.py +++ b/lib/matplotlib/tests/test_axes.py @@ -3262,16 +3262,16 @@ def test_stackplot(): y3 = 3.0 * x + 2 ax = fig.add_subplot(1, 1, 1) ax.stackplot(x, y1, y2, y3) - ax.set_xlim((0, 10)) - ax.set_ylim((0, 70)) + ax.set_xlim(0, 10) + ax.set_ylim(0, 70) # Reuse testcase from above for a test with labeled data and with colours # from the Axes property cycle. data = {"x": x, "y1": y1, "y2": y2, "y3": y3} fig, ax = plt.subplots() ax.stackplot("x", "y1", "y2", "y3", data=data, colors=["C0", "C1", "C2"]) - ax.set_xlim((0, 10)) - ax.set_ylim((0, 70)) + ax.set_xlim(0, 10) + ax.set_ylim(0, 70) @image_comparison(['stackplot_test_baseline.png'], remove_text=True) @@ -3308,16 +3308,16 @@ def test_stackplot_hatching(fig_ref, fig_test): # stackplot with different hatching styles (issue #27146) ax_test = fig_test.subplots() ax_test.stackplot(x, y1, y2, y3, hatch=["x", "//", "\\\\"], colors=["white"]) - ax_test.set_xlim((0, 10)) - ax_test.set_ylim((0, 70)) + ax_test.set_xlim(0, 10) + ax_test.set_ylim(0, 70) # compare with result from hatching each layer individually stack_baseline = np.zeros(len(x)) ax_ref = fig_ref.subplots() ax_ref.fill_between(x, stack_baseline, y1, hatch="x", facecolor="white") ax_ref.fill_between(x, y1, y1+y2, hatch="//", facecolor="white") ax_ref.fill_between(x, y1+y2, y1+y2+y3, hatch="\\\\", facecolor="white") - ax_ref.set_xlim((0, 10)) - ax_ref.set_ylim((0, 70)) + ax_ref.set_xlim(0, 10) + ax_ref.set_ylim(0, 70) def _bxp_test_helper( @@ -3594,13 +3594,13 @@ def test_boxplot(): fig, ax = plt.subplots() ax.boxplot([x, x], bootstrap=10000, notch=1) - ax.set_ylim((-30, 30)) + ax.set_ylim(-30, 30) # Reuse testcase from above for a labeled data test data = {"x": [x, x]} fig, ax = plt.subplots() ax.boxplot("x", bootstrap=10000, notch=1, data=data) - ax.set_ylim((-30, 30)) + ax.set_ylim(-30, 30) @check_figures_equal() @@ -3638,10 +3638,10 @@ def test_boxplot_sym2(): fig, [ax1, ax2] = plt.subplots(1, 2) ax1.boxplot([x, x], bootstrap=10000, sym='^') - ax1.set_ylim((-30, 30)) + ax1.set_ylim(-30, 30) ax2.boxplot([x, x], bootstrap=10000, sym='g') - ax2.set_ylim((-30, 30)) + ax2.set_ylim(-30, 30) @image_comparison(['boxplot_sym.png'], @@ -3654,7 +3654,7 @@ def test_boxplot_sym(): fig, ax = plt.subplots() ax.boxplot([x, x], sym='gs') - ax.set_ylim((-30, 30)) + ax.set_ylim(-30, 30) @image_comparison(['boxplot_autorange_false_whiskers.png', @@ -3669,11 +3669,11 @@ def test_boxplot_autorange_whiskers(): fig1, ax1 = plt.subplots() ax1.boxplot([x, x], bootstrap=10000, notch=1) - ax1.set_ylim((-5, 5)) + ax1.set_ylim(-5, 5) fig2, ax2 = plt.subplots() ax2.boxplot([x, x], bootstrap=10000, notch=1, autorange=True) - ax2.set_ylim((-5, 5)) + ax2.set_ylim(-5, 5) def _rc_test_bxp_helper(ax, rc_dict): @@ -3763,7 +3763,7 @@ def test_boxplot_with_CIarray(): # another with manual values ax.boxplot([x, x], bootstrap=10000, usermedians=[None, 1.0], conf_intervals=CIs, notch=1) - ax.set_ylim((-30, 30)) + ax.set_ylim(-30, 30) @image_comparison(['boxplot_no_inverted_whisker.png'], @@ -4352,7 +4352,7 @@ def test_errorbar_limits(): xlolims=xlolims, xuplims=xuplims, uplims=uplims, lolims=lolims, ls='none', mec='blue', capsize=0, color='cyan') - ax.set_xlim((0, 5.5)) + ax.set_xlim(0, 5.5) ax.set_title('Errorbar upper and lower limits') @@ -5282,8 +5282,8 @@ def test_vertex_markers(): fig, ax = plt.subplots() ax.plot(data, linestyle='', marker=marker_as_tuple, mfc='k') ax.plot(data[::-1], linestyle='', marker=marker_as_list, mfc='b') - ax.set_xlim([-1, 10]) - ax.set_ylim([-1, 10]) + ax.set_xlim(-1, 10) + ax.set_ylim(-1, 10) @image_comparison(['vline_hline_zorder.png', 'errorbar_zorder.png'], @@ -5552,8 +5552,8 @@ def test_step_linestyle(): ax.step(x, y, lw=5, linestyle=ls, where='pre') ax.step(x, y + 1, lw=5, linestyle=ls, where='mid') ax.step(x, y + 2, lw=5, linestyle=ls, where='post') - ax.set_xlim([-1, 5]) - ax.set_ylim([-1, 7]) + ax.set_xlim(-1, 5) + ax.set_ylim(-1, 7) # Reuse testcase from above for a labeled data test data = {"X": x, "Y0": y, "Y1": y+1, "Y2": y+2} @@ -5564,8 +5564,8 @@ def test_step_linestyle(): ax.step("X", "Y0", lw=5, linestyle=ls, where='pre', data=data) ax.step("X", "Y1", lw=5, linestyle=ls, where='mid', data=data) ax.step("X", "Y2", lw=5, linestyle=ls, where='post', data=data) - ax.set_xlim([-1, 5]) - ax.set_ylim([-1, 7]) + ax.set_xlim(-1, 5) + ax.set_ylim(-1, 7) @image_comparison(['mixed_collection'], remove_text=True) @@ -7126,7 +7126,7 @@ def shared_axes_generator(request): ax = ax_lst[0][0] elif request.param == 'add_axes': fig = plt.figure() - ax = fig.add_axes([.1, .1, .8, .8]) + ax = fig.add_axes((.1, .1, .8, .8)) return fig, ax @@ -7460,7 +7460,7 @@ def test_title_no_move_off_page(): # make sure that the automatic title repositioning does not get done. mpl.rcParams['axes.titley'] = None fig = plt.figure() - ax = fig.add_axes([0.1, -0.5, 0.8, 0.2]) + ax = fig.add_axes((0.1, -0.5, 0.8, 0.2)) ax.tick_params(axis="x", bottom=True, top=True, labelbottom=True, labeltop=True) tt = ax.set_title('Boo') @@ -7802,8 +7802,8 @@ def test_zoom_inset(): axin1 = ax.inset_axes([0.7, 0.7, 0.35, 0.35]) # redraw the data in the inset axes... axin1.pcolormesh(x, y, z[:-1, :-1]) - axin1.set_xlim([1.5, 2.15]) - axin1.set_ylim([2, 2.5]) + axin1.set_xlim(1.5, 2.15) + axin1.set_ylim(2, 2.5) axin1.set_aspect(ax.get_aspect()) with pytest.warns(mpl.MatplotlibDeprecationWarning): @@ -8399,7 +8399,7 @@ def test_aspect_nonlinear_adjustable_box(): def test_aspect_nonlinear_adjustable_datalim(): fig = plt.figure(figsize=(10, 10)) # Square. - ax = fig.add_axes([.1, .1, .8, .8]) # Square. + ax = fig.add_axes((.1, .1, .8, .8)) # Square. ax.plot([.4, .6], [.4, .6]) # Set minpos to keep logit happy. ax.set(xscale="log", xlim=(1, 100), yscale="logit", ylim=(1 / 101, 1 / 11), @@ -8623,7 +8623,7 @@ def test_multiplot_autoscale(): def test_sharing_does_not_link_positions(): fig = plt.figure() ax0 = fig.add_subplot(221) - ax1 = fig.add_axes([.6, .6, .3, .3], sharex=ax0) + ax1 = fig.add_axes((.6, .6, .3, .3), sharex=ax0) init_pos = ax1.get_position() fig.subplots_adjust(left=0) assert (ax1.get_position().get_points() == init_pos.get_points()).all() @@ -9722,7 +9722,7 @@ def test_axes_set_position_external_bbox_unchanged(fig_test, fig_ref): ax_test = fig_test.add_axes(bbox) ax_test.set_position([0.25, 0.25, 0.5, 0.5]) assert (bbox.x0, bbox.y0, bbox.width, bbox.height) == (0.0, 0.0, 1.0, 1.0) - ax_ref = fig_ref.add_axes([0.25, 0.25, 0.5, 0.5]) + ax_ref = fig_ref.add_axes((0.25, 0.25, 0.5, 0.5)) def test_bar_shape_mismatch(): diff --git a/lib/matplotlib/tests/test_axis.py b/lib/matplotlib/tests/test_axis.py index e33656ea9c17..5cb3ff4d3856 100644 --- a/lib/matplotlib/tests/test_axis.py +++ b/lib/matplotlib/tests/test_axis.py @@ -15,9 +15,9 @@ def test_axis_not_in_layout(): fig2, (ax2_left, ax2_right) = plt.subplots(ncols=2, layout='constrained') # 100 label overlapping the end of the axis - ax1_left.set_xlim([0, 100]) + ax1_left.set_xlim(0, 100) # 100 label not overlapping the end of the axis - ax2_left.set_xlim([0, 120]) + ax2_left.set_xlim(0, 120) for ax in ax1_left, ax2_left: ax.set_xticks([0, 100]) diff --git a/lib/matplotlib/tests/test_colorbar.py b/lib/matplotlib/tests/test_colorbar.py index f95f131e3bf6..ba20f325f4d7 100644 --- a/lib/matplotlib/tests/test_colorbar.py +++ b/lib/matplotlib/tests/test_colorbar.py @@ -332,11 +332,11 @@ def test_colorbar_closed_patch(): plt.rcParams['pcolormesh.snap'] = False fig = plt.figure(figsize=(8, 6)) - ax1 = fig.add_axes([0.05, 0.85, 0.9, 0.1]) - ax2 = fig.add_axes([0.1, 0.65, 0.75, 0.1]) - ax3 = fig.add_axes([0.05, 0.45, 0.9, 0.1]) - ax4 = fig.add_axes([0.05, 0.25, 0.9, 0.1]) - ax5 = fig.add_axes([0.05, 0.05, 0.9, 0.1]) + ax1 = fig.add_axes((0.05, 0.85, 0.9, 0.1)) + ax2 = fig.add_axes((0.1, 0.65, 0.75, 0.1)) + ax3 = fig.add_axes((0.05, 0.45, 0.9, 0.1)) + ax4 = fig.add_axes((0.05, 0.25, 0.9, 0.1)) + ax5 = fig.add_axes((0.05, 0.05, 0.9, 0.1)) cmap = mpl.colormaps["RdBu"].resampled(5) @@ -845,7 +845,7 @@ def test_colorbar_change_lim_scale(): pc = ax[1].pcolormesh(np.arange(100).reshape(10, 10)+1) cb = fig.colorbar(pc, ax=ax[1], extend='both') - cb.ax.set_ylim([20, 90]) + cb.ax.set_ylim(20, 90) @check_figures_equal() @@ -854,7 +854,7 @@ def test_axes_handles_same_functions(fig_ref, fig_test): for nn, fig in enumerate([fig_ref, fig_test]): ax = fig.add_subplot() pc = ax.pcolormesh(np.ones(300).reshape(10, 30)) - cax = fig.add_axes([0.9, 0.1, 0.03, 0.8]) + cax = fig.add_axes((0.9, 0.1, 0.03, 0.8)) cb = fig.colorbar(pc, cax=cax) if nn == 0: caxx = cax diff --git a/lib/matplotlib/tests/test_colors.py b/lib/matplotlib/tests/test_colors.py index 8d0f3467f045..04e9b82c6e6e 100644 --- a/lib/matplotlib/tests/test_colors.py +++ b/lib/matplotlib/tests/test_colors.py @@ -857,9 +857,9 @@ def test_boundarynorm_and_colorbarbase(): # Make a figure and axes with dimensions as desired. fig = plt.figure() - ax1 = fig.add_axes([0.05, 0.80, 0.9, 0.15]) - ax2 = fig.add_axes([0.05, 0.475, 0.9, 0.15]) - ax3 = fig.add_axes([0.05, 0.15, 0.9, 0.15]) + ax1 = fig.add_axes((0.05, 0.80, 0.9, 0.15)) + ax2 = fig.add_axes((0.05, 0.475, 0.9, 0.15)) + ax3 = fig.add_axes((0.05, 0.15, 0.9, 0.15)) # Set the colormap and bounds bounds = [-1, 2, 5, 7, 12, 15] diff --git a/lib/matplotlib/tests/test_constrainedlayout.py b/lib/matplotlib/tests/test_constrainedlayout.py index 7c7dd43a3115..05f4723cb7a4 100644 --- a/lib/matplotlib/tests/test_constrainedlayout.py +++ b/lib/matplotlib/tests/test_constrainedlayout.py @@ -309,7 +309,7 @@ def test_constrained_layout16(): """Test ax.set_position.""" fig, ax = plt.subplots(layout="constrained") example_plot(ax, fontsize=12) - ax2 = fig.add_axes([0.2, 0.2, 0.4, 0.4]) + ax2 = fig.add_axes((0.2, 0.2, 0.4, 0.4)) @image_comparison(['constrained_layout17.png'], style='mpl20') @@ -357,7 +357,7 @@ def test_constrained_layout20(): img = np.hypot(gx, gx[:, None]) fig = plt.figure() - ax = fig.add_axes([0, 0, 1, 1]) + ax = fig.add_axes((0, 0, 1, 1)) mesh = ax.pcolormesh(gx, gx, img[:-1, :-1]) fig.colorbar(mesh) diff --git a/lib/matplotlib/tests/test_dates.py b/lib/matplotlib/tests/test_dates.py index 73f10cec52aa..8ee12131fdbe 100644 --- a/lib/matplotlib/tests/test_dates.py +++ b/lib/matplotlib/tests/test_dates.py @@ -199,7 +199,7 @@ def test_too_many_date_ticks(caplog): tf = datetime.datetime(2000, 1, 20) fig, ax = plt.subplots() with pytest.warns(UserWarning) as rec: - ax.set_xlim((t0, tf), auto=True) + ax.set_xlim(t0, tf, auto=True) assert len(rec) == 1 assert ('Attempting to set identical low and high xlims' in str(rec[0].message)) diff --git a/lib/matplotlib/tests/test_figure.py b/lib/matplotlib/tests/test_figure.py index 014eb2cf23d0..5668c770c361 100644 --- a/lib/matplotlib/tests/test_figure.py +++ b/lib/matplotlib/tests/test_figure.py @@ -241,7 +241,7 @@ def test_gca(): fig = plt.figure() # test that gca() picks up Axes created via add_axes() - ax0 = fig.add_axes([0, 0, 1, 1]) + ax0 = fig.add_axes((0, 0, 1, 1)) assert fig.gca() is ax0 # test that gca() picks up Axes created via add_subplot() @@ -546,7 +546,7 @@ def test_invalid_figure_add_axes(): fig.add_axes((.1, .1, .5, np.nan)) with pytest.raises(TypeError, match="multiple values for argument 'rect'"): - fig.add_axes([0, 0, 1, 1], rect=[0, 0, 1, 1]) + fig.add_axes((0, 0, 1, 1), rect=[0, 0, 1, 1]) fig2, ax = plt.subplots() with pytest.raises(ValueError, @@ -559,7 +559,7 @@ def test_invalid_figure_add_axes(): fig2.add_axes(ax, "extra positional argument") with pytest.raises(TypeError, match=r"add_axes\(\) takes 1 positional arguments"): - fig.add_axes([0, 0, 1, 1], "extra positional argument") + fig.add_axes((0, 0, 1, 1), "extra positional argument") def test_subplots_shareax_loglabels(): @@ -1583,22 +1583,22 @@ def test_add_subplot_kwargs(): def test_add_axes_kwargs(): # fig.add_axes() always creates new axes, even if axes kwargs differ. fig = plt.figure() - ax = fig.add_axes([0, 0, 1, 1]) - ax1 = fig.add_axes([0, 0, 1, 1]) + ax = fig.add_axes((0, 0, 1, 1)) + ax1 = fig.add_axes((0, 0, 1, 1)) assert ax is not None assert ax1 is not ax plt.close() fig = plt.figure() - ax = fig.add_axes([0, 0, 1, 1], projection='polar') - ax1 = fig.add_axes([0, 0, 1, 1], projection='polar') + ax = fig.add_axes((0, 0, 1, 1), projection='polar') + ax1 = fig.add_axes((0, 0, 1, 1), projection='polar') assert ax is not None assert ax1 is not ax plt.close() fig = plt.figure() - ax = fig.add_axes([0, 0, 1, 1], projection='polar') - ax1 = fig.add_axes([0, 0, 1, 1]) + ax = fig.add_axes((0, 0, 1, 1), projection='polar') + ax1 = fig.add_axes((0, 0, 1, 1)) assert ax is not None assert ax1.name == 'rectilinear' assert ax1 is not ax diff --git a/lib/matplotlib/tests/test_image.py b/lib/matplotlib/tests/test_image.py index 93124141487f..271fe6755a15 100644 --- a/lib/matplotlib/tests/test_image.py +++ b/lib/matplotlib/tests/test_image.py @@ -114,12 +114,12 @@ def test_imshow_zoom(fig_test, fig_ref): fig.set_size_inches(2.9, 2.9) ax = fig_test.subplots() ax.imshow(A, interpolation='auto') - ax.set_xlim([10, 20]) - ax.set_ylim([10, 20]) + ax.set_xlim(10, 20) + ax.set_ylim(10, 20) ax = fig_ref.subplots() ax.imshow(A, interpolation='nearest') - ax.set_xlim([10, 20]) - ax.set_ylim([10, 20]) + ax.set_xlim(10, 20) + ax.set_ylim(10, 20) @check_figures_equal() @@ -504,7 +504,7 @@ def test_image_shift(): def test_image_edges(): fig = plt.figure(figsize=[1, 1]) - ax = fig.add_axes([0, 0, 1, 1], frameon=False) + ax = fig.add_axes((0, 0, 1, 1), frameon=False) data = np.tile(np.arange(12), 15).reshape(20, 9) @@ -512,8 +512,8 @@ def test_image_edges(): interpolation='none', cmap='gray') x = y = 2 - ax.set_xlim([-x, x]) - ax.set_ylim([-y, y]) + ax.set_xlim(-x, x) + ax.set_ylim(-y, y) ax.set_xticks([]) ax.set_yticks([]) @@ -538,7 +538,7 @@ def test_image_composite_background(): ax.imshow(arr, extent=[0, 2, 15, 0]) ax.imshow(arr, extent=[4, 6, 15, 0]) ax.set_facecolor((1, 0, 0, 0.5)) - ax.set_xlim([0, 12]) + ax.set_xlim(0, 12) @image_comparison(['image_composite_alpha'], remove_text=True, tol=0.07) @@ -564,8 +564,8 @@ def test_image_composite_alpha(): ax.imshow(arr2, extent=[0, 5, 2, 3], alpha=0.6) ax.imshow(arr2, extent=[0, 5, 3, 4], alpha=0.3) ax.set_facecolor((0, 0.5, 0, 1)) - ax.set_xlim([0, 5]) - ax.set_ylim([5, 0]) + ax.set_xlim(0, 5) + ax.set_ylim(5, 0) @check_figures_equal(extensions=["pdf"]) @@ -1192,7 +1192,7 @@ def test_exact_vmin(): # make the image exactly 190 pixels wide fig = plt.figure(figsize=(1.9, 0.1), dpi=100) - ax = fig.add_axes([0, 0, 1, 1]) + ax = fig.add_axes((0, 0, 1, 1)) data = np.array( [[-1, -1, -1, 0, 0, 0, 0, 43, 79, 95, 66, 1, -1, -1, -1, 0, 0, 0, 34]], @@ -1469,8 +1469,8 @@ def test_rgba_antialias(): axs = axs.flatten() # zoom in axs[0].imshow(aa, interpolation='nearest', cmap=cmap, vmin=-1.2, vmax=1.2) - axs[0].set_xlim([N/2-25, N/2+25]) - axs[0].set_ylim([N/2+50, N/2-10]) + axs[0].set_xlim(N/2-25, N/2+25) + axs[0].set_ylim(N/2+50, N/2-10) # no anti-alias axs[1].imshow(aa, interpolation='nearest', cmap=cmap, vmin=-1.2, vmax=1.2) diff --git a/lib/matplotlib/tests/test_legend.py b/lib/matplotlib/tests/test_legend.py index 9c708598e27c..a073fa839d50 100644 --- a/lib/matplotlib/tests/test_legend.py +++ b/lib/matplotlib/tests/test_legend.py @@ -518,8 +518,8 @@ def test_legend_stackplot(): y2 = 2.0 * x + 1 y3 = 3.0 * x + 2 ax.stackplot(x, y1, y2, y3, labels=['y1', 'y2', 'y3']) - ax.set_xlim((0, 10)) - ax.set_ylim((0, 70)) + ax.set_xlim(0, 10) + ax.set_ylim(0, 70) ax.legend(loc='best') diff --git a/lib/matplotlib/tests/test_lines.py b/lib/matplotlib/tests/test_lines.py index 56bded0c6557..88f96d1b6555 100644 --- a/lib/matplotlib/tests/test_lines.py +++ b/lib/matplotlib/tests/test_lines.py @@ -219,8 +219,8 @@ def test_marker_fill_styles(): markeredgecolor=color, markeredgewidth=2) - ax.set_ylim([0, 7.5]) - ax.set_xlim([-5, 155]) + ax.set_ylim(0, 7.5) + ax.set_xlim(-5, 155) def test_markerfacecolor_fillstyle(): diff --git a/lib/matplotlib/tests/test_marker.py b/lib/matplotlib/tests/test_marker.py index f6e20c148897..a1e71f1f6533 100644 --- a/lib/matplotlib/tests/test_marker.py +++ b/lib/matplotlib/tests/test_marker.py @@ -181,9 +181,9 @@ def test_marker_clipping(fig_ref, fig_test): width = 2 * marker_size * ncol height = 2 * marker_size * nrow * 2 fig_ref.set_size_inches((width / fig_ref.dpi, height / fig_ref.dpi)) - ax_ref = fig_ref.add_axes([0, 0, 1, 1]) + ax_ref = fig_ref.add_axes((0, 0, 1, 1)) fig_test.set_size_inches((width / fig_test.dpi, height / fig_ref.dpi)) - ax_test = fig_test.add_axes([0, 0, 1, 1]) + ax_test = fig_test.add_axes((0, 0, 1, 1)) for i, marker in enumerate(markers.MarkerStyle.markers): x = i % ncol diff --git a/lib/matplotlib/tests/test_offsetbox.py b/lib/matplotlib/tests/test_offsetbox.py index f18fa7c777d1..cd693c64ee3f 100644 --- a/lib/matplotlib/tests/test_offsetbox.py +++ b/lib/matplotlib/tests/test_offsetbox.py @@ -48,8 +48,8 @@ def test_offsetbox_clipping(): da.add_artist(bg) da.add_artist(line) ax.add_artist(anchored_box) - ax.set_xlim((0, 1)) - ax.set_ylim((0, 1)) + ax.set_xlim(0, 1) + ax.set_ylim(0, 1) def test_offsetbox_clip_children(): @@ -455,7 +455,7 @@ def test_remove_draggable(): def test_draggable_in_subfigure(): fig = plt.figure() # Put annotation at lower left corner to make it easily pickable below. - ann = fig.subfigures().add_axes([0, 0, 1, 1]).annotate("foo", (0, 0)) + ann = fig.subfigures().add_axes((0, 0, 1, 1)).annotate("foo", (0, 0)) ann.draggable(True) fig.canvas.draw() # Texts are non-pickable until the first draw. MouseEvent("button_press_event", fig.canvas, 1, 1)._process() diff --git a/lib/matplotlib/tests/test_path.py b/lib/matplotlib/tests/test_path.py index 5424160dad93..88bb5840a97f 100644 --- a/lib/matplotlib/tests/test_path.py +++ b/lib/matplotlib/tests/test_path.py @@ -155,8 +155,8 @@ def test_nonlinear_containment(): def test_arrow_contains_point(): # fix bug (#8384) fig, ax = plt.subplots() - ax.set_xlim((0, 2)) - ax.set_ylim((0, 2)) + ax.set_xlim(0, 2) + ax.set_ylim(0, 2) # create an arrow with Curve style arrow = patches.FancyArrowPatch((0.5, 0.25), (1.5, 0.75), diff --git a/lib/matplotlib/tests/test_polar.py b/lib/matplotlib/tests/test_polar.py index a0969df5de90..31e8cdd89a21 100644 --- a/lib/matplotlib/tests/test_polar.py +++ b/lib/matplotlib/tests/test_polar.py @@ -150,7 +150,7 @@ def test_polar_rmin(): theta = 2*np.pi*r fig = plt.figure() - ax = fig.add_axes([0.1, 0.1, 0.8, 0.8], polar=True) + ax = fig.add_axes((0.1, 0.1, 0.8, 0.8), polar=True) ax.plot(theta, r) ax.set_rmax(2.0) ax.set_rmin(0.5) @@ -162,7 +162,7 @@ def test_polar_negative_rmin(): theta = 2*np.pi*r fig = plt.figure() - ax = fig.add_axes([0.1, 0.1, 0.8, 0.8], polar=True) + ax = fig.add_axes((0.1, 0.1, 0.8, 0.8), polar=True) ax.plot(theta, r) ax.set_rmax(0.0) ax.set_rmin(-3.0) @@ -174,7 +174,7 @@ def test_polar_rorigin(): theta = 2*np.pi*r fig = plt.figure() - ax = fig.add_axes([0.1, 0.1, 0.8, 0.8], polar=True) + ax = fig.add_axes((0.1, 0.1, 0.8, 0.8), polar=True) ax.plot(theta, r) ax.set_rmax(2.0) ax.set_rmin(0.5) @@ -184,14 +184,14 @@ def test_polar_rorigin(): @image_comparison(['polar_invertedylim.png'], style='default') def test_polar_invertedylim(): fig = plt.figure() - ax = fig.add_axes([0.1, 0.1, 0.8, 0.8], polar=True) + ax = fig.add_axes((0.1, 0.1, 0.8, 0.8), polar=True) ax.set_ylim(2, 0) @image_comparison(['polar_invertedylim_rorigin.png'], style='default') def test_polar_invertedylim_rorigin(): fig = plt.figure() - ax = fig.add_axes([0.1, 0.1, 0.8, 0.8], polar=True) + ax = fig.add_axes((0.1, 0.1, 0.8, 0.8), polar=True) ax.yaxis.set_inverted(True) # Set the rlims to inverted (2, 0) without calling set_rlim, to check that # viewlims are correctly unstaled before draw()ing. @@ -206,7 +206,7 @@ def test_polar_theta_position(): theta = 2*np.pi*r fig = plt.figure() - ax = fig.add_axes([0.1, 0.1, 0.8, 0.8], polar=True) + ax = fig.add_axes((0.1, 0.1, 0.8, 0.8), polar=True) ax.plot(theta, r) ax.set_theta_zero_location("NW", 30) ax.set_theta_direction('clockwise') diff --git a/lib/matplotlib/tests/test_simplification.py b/lib/matplotlib/tests/test_simplification.py index bc9b46b14db2..41d01addd622 100644 --- a/lib/matplotlib/tests/test_simplification.py +++ b/lib/matplotlib/tests/test_simplification.py @@ -25,7 +25,7 @@ def test_clipping(): fig, ax = plt.subplots() ax.plot(t, s, linewidth=1.0) - ax.set_ylim((-0.20, -0.28)) + ax.set_ylim(-0.20, -0.28) @image_comparison(['overflow'], remove_text=True, @@ -244,8 +244,8 @@ def test_simplify_curve(): fig, ax = plt.subplots() ax.add_patch(pp1) - ax.set_xlim((0, 2)) - ax.set_ylim((0, 2)) + ax.set_xlim(0, 2) + ax.set_ylim(0, 2) @check_figures_equal(extensions=['png', 'pdf', 'svg']) @@ -401,8 +401,8 @@ def test_closed_path_clipping(fig_test, fig_ref): def test_hatch(): fig, ax = plt.subplots() ax.add_patch(plt.Rectangle((0, 0), 1, 1, fill=False, hatch="/")) - ax.set_xlim((0.45, 0.55)) - ax.set_ylim((0.45, 0.55)) + ax.set_xlim(0.45, 0.55) + ax.set_ylim(0.45, 0.55) @image_comparison(['fft_peaks'], remove_text=True) diff --git a/lib/matplotlib/tests/test_text.py b/lib/matplotlib/tests/test_text.py index 79a9e2d66c46..7327ed55ed04 100644 --- a/lib/matplotlib/tests/test_text.py +++ b/lib/matplotlib/tests/test_text.py @@ -144,8 +144,8 @@ def test_multiline2(): fig, ax = plt.subplots() - ax.set_xlim([0, 1.4]) - ax.set_ylim([0, 2]) + ax.set_xlim(0, 1.4) + ax.set_ylim(0, 2) ax.axhline(0.5, color='C2', linewidth=0.3) sts = ['Line', '2 Lineg\n 2 Lg', '$\\sum_i x $', 'hi $\\sum_i x $\ntest', 'test\n $\\sum_i x $', '$\\sum_i x $\n $\\sum_i x $'] diff --git a/lib/matplotlib/tests/test_tightlayout.py b/lib/matplotlib/tests/test_tightlayout.py index f6b6d8f644cc..98fd5e70cdb9 100644 --- a/lib/matplotlib/tests/test_tightlayout.py +++ b/lib/matplotlib/tests/test_tightlayout.py @@ -331,8 +331,8 @@ def test_collapsed(): # zero (i.e. margins add up to more than the available width) that a call # to tight_layout will not get applied: fig, ax = plt.subplots(tight_layout=True) - ax.set_xlim([0, 1]) - ax.set_ylim([0, 1]) + ax.set_xlim(0, 1) + ax.set_ylim(0, 1) ax.annotate('BIG LONG STRING', xy=(1.25, 2), xytext=(10.5, 1.75), annotation_clip=False) diff --git a/lib/matplotlib/tests/test_usetex.py b/lib/matplotlib/tests/test_usetex.py index c7658c4f42ac..1d640b4adf7c 100644 --- a/lib/matplotlib/tests/test_usetex.py +++ b/lib/matplotlib/tests/test_usetex.py @@ -168,8 +168,8 @@ def test_rotation(): mpl.rcParams['text.usetex'] = True fig = plt.figure() - ax = fig.add_axes([0, 0, 1, 1]) - ax.set(xlim=[-0.5, 5], xticks=[], ylim=[-0.5, 3], yticks=[], frame_on=False) + ax = fig.add_axes((0, 0, 1, 1)) + ax.set(xlim=(-0.5, 5), xticks=[], ylim=(-0.5, 3), yticks=[], frame_on=False) text = {val: val[0] for val in ['top', 'center', 'bottom', 'left', 'right']} text['baseline'] = 'B' diff --git a/lib/matplotlib/widgets.py b/lib/matplotlib/widgets.py index 6b196571814d..9ded7c61ce2d 100644 --- a/lib/matplotlib/widgets.py +++ b/lib/matplotlib/widgets.py @@ -273,10 +273,10 @@ def __init__(self, ax, orientation, closedmin, closedmax, self.valfmt = valfmt if orientation == "vertical": - ax.set_ylim((valmin, valmax)) + ax.set_ylim(valmin, valmax) axis = ax.yaxis else: - ax.set_xlim((valmin, valmax)) + ax.set_xlim(valmin, valmax) axis = ax.xaxis self._fmt = axis.get_major_formatter() @@ -1841,7 +1841,7 @@ def __init__(self, targetfig, toolfig): self.sliderbottom.slidermax = self.slidertop self.slidertop.slidermin = self.sliderbottom - bax = toolfig.add_axes([0.8, 0.05, 0.15, 0.075]) + bax = toolfig.add_axes((0.8, 0.05, 0.15, 0.075)) self.buttonreset = Button(bax, 'Reset') self.buttonreset.on_clicked(self._on_reset) diff --git a/lib/mpl_toolkits/axes_grid1/tests/test_axes_grid1.py b/lib/mpl_toolkits/axes_grid1/tests/test_axes_grid1.py index 496ce74d72c0..6748c1d7e1c0 100644 --- a/lib/mpl_toolkits/axes_grid1/tests/test_axes_grid1.py +++ b/lib/mpl_toolkits/axes_grid1/tests/test_axes_grid1.py @@ -678,7 +678,7 @@ def test_mark_inset_unstales_viewlim(fig_test, fig_ref): def test_auto_adjustable(): fig = plt.figure() - ax = fig.add_axes([0, 0, 1, 1]) + ax = fig.add_axes((0, 0, 1, 1)) pad = 0.1 make_axes_area_auto_adjustable(ax, pad=pad) fig.canvas.draw() diff --git a/lib/mpl_toolkits/axisartist/tests/test_axislines.py b/lib/mpl_toolkits/axisartist/tests/test_axislines.py index 8bc3707421b6..a1485d4f436b 100644 --- a/lib/mpl_toolkits/axisartist/tests/test_axislines.py +++ b/lib/mpl_toolkits/axisartist/tests/test_axislines.py @@ -83,8 +83,8 @@ def test_ParasiteAxesAuxTrans(): getattr(ax2, name)(xx, yy, data[:-1, :-1]) else: getattr(ax2, name)(xx, yy, data) - ax1.set_xlim((0, 5)) - ax1.set_ylim((0, 5)) + ax1.set_xlim(0, 5) + ax1.set_ylim(0, 5) ax2.contour(xx, yy, data, colors='k') diff --git a/lib/mpl_toolkits/mplot3d/tests/test_axes3d.py b/lib/mpl_toolkits/mplot3d/tests/test_axes3d.py index 79c7baba9bd1..cd45c8e33a6f 100644 --- a/lib/mpl_toolkits/mplot3d/tests/test_axes3d.py +++ b/lib/mpl_toolkits/mplot3d/tests/test_axes3d.py @@ -2227,9 +2227,9 @@ def test_computed_zorder(): # plot some points ax.scatter((3, 3), (1, 3), (1, 3), c='red', zorder=10) - ax.set_xlim((0, 5.0)) - ax.set_ylim((0, 5.0)) - ax.set_zlim((0, 2.5)) + ax.set_xlim(0, 5.0) + ax.set_ylim(0, 5.0) + ax.set_zlim(0, 2.5) ax3 = fig.add_subplot(223, projection='3d') ax4 = fig.add_subplot(224, projection='3d') diff --git a/tools/make_icons.py b/tools/make_icons.py index f09d40e92256..b253c0517c43 100755 --- a/tools/make_icons.py +++ b/tools/make_icons.py @@ -64,7 +64,7 @@ def make_icon(font_path, ccode): def make_matplotlib_icon(): fig = plt.figure(figsize=(1, 1)) fig.patch.set_alpha(0.0) - ax = fig.add_axes([0.025, 0.025, 0.95, 0.95], projection='polar') + ax = fig.add_axes((0.025, 0.025, 0.95, 0.95), projection='polar') ax.set_axisbelow(True) N = 7