diff --git a/lib/matplotlib/tests/test_agg_filter.py b/lib/matplotlib/tests/test_agg_filter.py index 9e0b5a0c3afa..4c5b55a3d15c 100644 --- a/lib/matplotlib/tests/test_agg_filter.py +++ b/lib/matplotlib/tests/test_agg_filter.py @@ -5,7 +5,7 @@ @image_comparison(baseline_images=['agg_filter_alpha'], - extensions=['gif', 'png', 'pdf']) + extensions=['gif', 'png', 'pdf'], style='mpl20') def test_agg_filter_alpha(): ax = plt.axes() x, y = np.mgrid[0:7, 0:8] diff --git a/lib/matplotlib/tests/test_arrow_patches.py b/lib/matplotlib/tests/test_arrow_patches.py index 9cf1636f7913..08d3d62f0a84 100644 --- a/lib/matplotlib/tests/test_arrow_patches.py +++ b/lib/matplotlib/tests/test_arrow_patches.py @@ -28,7 +28,7 @@ def test_fancyarrow(): ax.tick_params(labelleft=False, labelbottom=False) -@image_comparison(['boxarrow_test_image.png']) +@image_comparison(['boxarrow_test_image.png'], style='mpl20') def test_boxarrow(): styles = mpatches.BoxStyle.get_styles() diff --git a/lib/matplotlib/tests/test_axes.py b/lib/matplotlib/tests/test_axes.py index 25b93eb57b26..315722b8fd36 100644 --- a/lib/matplotlib/tests/test_axes.py +++ b/lib/matplotlib/tests/test_axes.py @@ -240,13 +240,13 @@ def test_matshow(fig_test, fig_ref): # TODO: tighten tolerance after baseline image is regenerated for text overhaul -@image_comparison([f'formatter_ticker_{i:03d}.png' for i in range(1, 6)], +@image_comparison([f'formatter_ticker_{i:03d}.png' for i in range(1, 6)], style='mpl20', tol=0.02 if platform.machine() == 'x86_64' else 0.04) def test_formatter_ticker(): import matplotlib.testing.jpl_units as units units.register() - # This should affect the tick size. (Tests issue #543) + # This should not affect the tick size. (Tests issue #543) matplotlib.rcParams['lines.markeredgewidth'] = 30 # This essentially test to see if user specified labels get overwritten @@ -332,7 +332,7 @@ def test_strmethodformatter_auto_formatter(): assert ax.yaxis.get_minor_formatter().fmt == targ_strformatter.fmt -@image_comparison(["twin_axis_locators_formatters.png"]) +@image_comparison(["twin_axis_locators_formatters.png"], style='mpl20') def test_twin_axis_locators_formatters(): vals = np.linspace(0, 1, num=5, endpoint=True) locs = np.sin(np.pi * vals / 2.0) @@ -342,6 +342,7 @@ def test_twin_axis_locators_formatters(): fig = plt.figure() ax1 = fig.add_subplot(1, 1, 1) + ax1.margins(0) ax1.plot([0.1, 100], [0, 1]) ax1.yaxis.set_major_locator(majl) ax1.yaxis.set_minor_locator(minl) @@ -735,7 +736,7 @@ def test_nargs_pcolorfast(): ax.pcolorfast([(0, 1), (0, 2)], [[1, 2, 3], [1, 2, 3]]) -@image_comparison(['offset_points'], remove_text=True) +@image_comparison(['offset_points'], remove_text=True, style='mpl20') def test_basic_annotate(): # Setup some data t = np.arange(0.0, 5.0, 0.01) @@ -811,7 +812,7 @@ def test_annotate_signature(): # TODO: tighten tolerance after baseline image is regenerated for text overhaul -@image_comparison(['fill_units.png'], savefig_kwarg={'dpi': 60}, tol=0.2) +@image_comparison(['fill_units.png'], savefig_kwarg={'dpi': 60}, style='mpl20', tol=0.2) def test_fill_units(): import matplotlib.testing.jpl_units as units units.register() @@ -876,7 +877,7 @@ def test_errorbar_mapview_kwarg(): ax.errorbar(x=D.keys(), y=D.values(), xerr=D.values()) -@image_comparison(['single_point', 'single_point']) +@image_comparison(['single_point', 'single_point'], style='mpl20') def test_single_point(): # Issue #1796: don't let lines.marker affect the grid matplotlib.rcParams['lines.marker'] = 'o' @@ -935,7 +936,7 @@ def test_aitoff_proj(): ax.plot(X.flat, Y.flat, 'o', markersize=4) -@image_comparison(['axvspan_epoch.png']) +@image_comparison(['axvspan_epoch.png'], style='mpl20') def test_axvspan_epoch(): import matplotlib.testing.jpl_units as units units.register() @@ -950,7 +951,7 @@ def test_axvspan_epoch(): ax.set_xlim(t0 - 5.0*dt, tf + 5.0*dt) -@image_comparison(['axhspan_epoch.png'], tol=0.02) +@image_comparison(['axhspan_epoch.png'], style='mpl20', tol=0.02) def test_axhspan_epoch(): import matplotlib.testing.jpl_units as units units.register() @@ -1148,7 +1149,7 @@ def test_inverted_limits(): assert ax.get_ylim() == (10, 1) -@image_comparison(['nonfinite_limits']) +@image_comparison(['nonfinite_limits'], style='mpl20') def test_nonfinite_limits(): x = np.arange(0., np.e, 0.01) # silence divide by zero warning from log(0) @@ -1342,7 +1343,7 @@ def test_fill_between_interpolate_nan(): # test_symlog and test_symlog2 used to have baseline images in all three # formats, but the png and svg baselines got invalidated by the removal of # minor tick overstriking. -@image_comparison(['symlog.pdf']) +@image_comparison(['symlog.pdf'], style='mpl20') def test_symlog(): x = np.array([0, 1, 2, 4, 6, 9, 12, 24]) y = np.array([1000000, 500000, 100000, 100, 5, 0, 0, 0]) @@ -1751,8 +1752,8 @@ def test_pcolorauto(fig_test, fig_ref, snap): ax.pcolormesh(x2, y2, Z, snap=snap) -@image_comparison(['canonical'], - tol=0 if platform.machine() == 'x86_64' else 0.02) +@image_comparison(['canonical'], style='mpl20', + tol=0 if platform.machine() == 'x86_64' else 0.03) def test_canonical(): fig, ax = plt.subplots() ax.plot([1, 2, 3]) @@ -1837,7 +1838,7 @@ def test_marker_as_markerstyle(): ax.errorbar([1, 2, 3], [5, 4, 3], marker=m) -@image_comparison(['markevery.png'], remove_text=True) +@image_comparison(['markevery.png'], remove_text=True, style='mpl20') def test_markevery(): x = np.linspace(0, 10, 100) y = np.sin(x) * np.sqrt(x/10 + 0.5) @@ -1845,13 +1846,13 @@ def test_markevery(): # check marker only plot fig, ax = plt.subplots() ax.plot(x, y, 'o', label='default') - ax.plot(x, y, 'd', markevery=None, label='mark all') - ax.plot(x, y, 's', markevery=10, label='mark every 10') - ax.plot(x, y, '+', markevery=(5, 20), label='mark every 5 starting at 10') + ax.plot(x, y+1, 'd', markevery=None, label='mark all') + ax.plot(x, y+2, 's', markevery=10, label='mark every 10') + ax.plot(x, y+3, '+', markevery=(5, 20), label='mark every 20 starting at 5') ax.legend() -@image_comparison(['markevery_line.png'], remove_text=True, tol=0.005) +@image_comparison(['markevery_line.png'], remove_text=True, style='mpl20', tol=0.005) def test_markevery_line(): # TODO: a slight change in rendering between Inkscape versions may explain # why one had to introduce a small non-zero tolerance for the SVG test @@ -1863,9 +1864,9 @@ def test_markevery_line(): # check line/marker combos fig, ax = plt.subplots() ax.plot(x, y, '-o', label='default') - ax.plot(x, y, '-d', markevery=None, label='mark all') - ax.plot(x, y, '-s', markevery=10, label='mark every 10') - ax.plot(x, y, '-+', markevery=(5, 20), label='mark every 5 starting at 10') + ax.plot(x, y+1, '-d', markevery=None, label='mark all') + ax.plot(x, y+2, '-s', markevery=10, label='mark every 10') + ax.plot(x, y+3, '-+', markevery=(5, 20), label='mark every 20 starting at 5') ax.legend() @@ -2007,7 +2008,8 @@ def test_marker_edges(): ax.plot(x+0.2, np.sin(x), 'y.', ms=30.0, mew=2, mec='b') -@image_comparison(['bar_tick_label_single.png', 'bar_tick_label_single.png']) +@image_comparison(['bar_tick_label_single.png', 'bar_tick_label_single.png'], + style='mpl20') def test_bar_tick_label_single(): # From 2516: plot bar with array of string labels for x axis ax = plt.gca() @@ -2030,7 +2032,7 @@ def test_bar_ticklabel_fail(): ax.bar([], []) -@image_comparison(['bar_tick_label_multiple.png']) +@image_comparison(['bar_tick_label_multiple.png'], style='mpl20') def test_bar_tick_label_multiple(): # From 2516: plot bar with array of string labels for x axis ax = plt.gca() @@ -2038,7 +2040,7 @@ def test_bar_tick_label_multiple(): align='center') -@image_comparison(['bar_tick_label_multiple_old_label_alignment.png']) +@image_comparison(['bar_tick_label_multiple_old_label_alignment.png'], style='mpl20') def test_bar_tick_label_multiple_old_alignment(): # Test that the alignment for class is backward compatible matplotlib.rcParams["ytick.alignment"] = "center" @@ -2119,7 +2121,7 @@ def test_bar_edgecolor_none_alpha(): assert rect.get_edgecolor() == (0, 0, 0, 0) -@image_comparison(['barh_tick_label.png']) +@image_comparison(['barh_tick_label.png'], style='mpl20') def test_barh_tick_label(): # From 2516: plot barh with array of string labels for y axis ax = plt.gca() @@ -2518,7 +2520,7 @@ def test_hist_step_filled(): assert all(p.get_facecolor() == p.get_edgecolor() for p in patches) -@image_comparison(['hist_density.png']) +@image_comparison(['hist_density.png'], style='mpl20') def test_hist_density(): np.random.seed(19680801) data = np.random.standard_normal(2000) @@ -2752,7 +2754,7 @@ def test_stairs_invalid_update2(): h.set_data(edges=np.arange(5)) -@image_comparison(['test_stairs_options.png'], remove_text=True) +@image_comparison(['test_stairs_options.png'], style='mpl20', remove_text=True) def test_stairs_options(): x, y = np.array([1, 2, 3, 4, 5]), np.array([1, 2, 3, 4]).astype(float) yn = y.copy() @@ -2777,7 +2779,7 @@ def test_stairs_options(): # TODO: tighten tolerance after baseline image is regenerated for text overhaul -@image_comparison(['test_stairs_datetime.png'], tol=0.2) +@image_comparison(['test_stairs_datetime.png'], style='mpl20', tol=0.2) def test_stairs_datetime(): f, ax = plt.subplots(constrained_layout=True) ax.stairs(np.arange(36), @@ -3401,6 +3403,7 @@ def test_log_scales_invalid(): @image_comparison(['stackplot_test_image.png', 'stackplot_test_image.png'], + style='mpl20', tol=0 if platform.machine() == 'x86_64' else 0.031) def test_stackplot(): fig = plt.figure() @@ -4017,7 +4020,7 @@ def test_boxplot_mod_artist_after_plotting(): @image_comparison(['violinplot_vert_baseline.png', - 'violinplot_vert_baseline.png']) + 'violinplot_vert_baseline.png'], style='mpl20') def test_vert_violinplot_baseline(): # First 9 digits of frac(sqrt(2)) np.random.seed(414213562) @@ -4033,7 +4036,7 @@ def test_vert_violinplot_baseline(): showmedians=False, data=data) -@image_comparison(['violinplot_vert_showmeans.png']) +@image_comparison(['violinplot_vert_showmeans.png'], style='mpl20') def test_vert_violinplot_showmeans(): ax = plt.axes() # First 9 digits of frac(sqrt(3)) @@ -4043,7 +4046,7 @@ def test_vert_violinplot_showmeans(): showmedians=False) -@image_comparison(['violinplot_vert_showextrema.png']) +@image_comparison(['violinplot_vert_showextrema.png'], style='mpl20') def test_vert_violinplot_showextrema(): ax = plt.axes() # First 9 digits of frac(sqrt(5)) @@ -4053,7 +4056,7 @@ def test_vert_violinplot_showextrema(): showmedians=False) -@image_comparison(['violinplot_vert_showmedians.png']) +@image_comparison(['violinplot_vert_showmedians.png'], style='mpl20') def test_vert_violinplot_showmedians(): ax = plt.axes() # First 9 digits of frac(sqrt(7)) @@ -4063,7 +4066,7 @@ def test_vert_violinplot_showmedians(): showmedians=True) -@image_comparison(['violinplot_vert_showall.png']) +@image_comparison(['violinplot_vert_showall.png'], style='mpl20') def test_vert_violinplot_showall(): ax = plt.axes() # First 9 digits of frac(sqrt(11)) @@ -4074,7 +4077,7 @@ def test_vert_violinplot_showall(): quantiles=[[0.1, 0.9], [0.2, 0.8], [0.3, 0.7], [0.4, 0.6]]) -@image_comparison(['violinplot_vert_custompoints_10.png']) +@image_comparison(['violinplot_vert_custompoints_10.png'], style='mpl20') def test_vert_violinplot_custompoints_10(): ax = plt.axes() # First 9 digits of frac(sqrt(13)) @@ -4084,7 +4087,7 @@ def test_vert_violinplot_custompoints_10(): showmedians=False, points=10) -@image_comparison(['violinplot_vert_custompoints_200.png']) +@image_comparison(['violinplot_vert_custompoints_200.png'], style='mpl20') def test_vert_violinplot_custompoints_200(): ax = plt.axes() # First 9 digits of frac(sqrt(17)) @@ -4094,7 +4097,7 @@ def test_vert_violinplot_custompoints_200(): showmedians=False, points=200) -@image_comparison(['violinplot_horiz_baseline.png']) +@image_comparison(['violinplot_horiz_baseline.png'], style='mpl20') def test_horiz_violinplot_baseline(): ax = plt.axes() # First 9 digits of frac(sqrt(19)) @@ -4104,7 +4107,7 @@ def test_horiz_violinplot_baseline(): showextrema=False, showmedians=False) -@image_comparison(['violinplot_horiz_showmedians.png']) +@image_comparison(['violinplot_horiz_showmedians.png'], style='mpl20') def test_horiz_violinplot_showmedians(): ax = plt.axes() # First 9 digits of frac(sqrt(23)) @@ -4114,7 +4117,7 @@ def test_horiz_violinplot_showmedians(): showextrema=False, showmedians=True) -@image_comparison(['violinplot_horiz_showmeans.png']) +@image_comparison(['violinplot_horiz_showmeans.png'], style='mpl20') def test_horiz_violinplot_showmeans(): ax = plt.axes() # First 9 digits of frac(sqrt(29)) @@ -4124,7 +4127,7 @@ def test_horiz_violinplot_showmeans(): showextrema=False, showmedians=False) -@image_comparison(['violinplot_horiz_showextrema.png']) +@image_comparison(['violinplot_horiz_showextrema.png'], style='mpl20') def test_horiz_violinplot_showextrema(): ax = plt.axes() # First 9 digits of frac(sqrt(31)) @@ -4134,7 +4137,7 @@ def test_horiz_violinplot_showextrema(): showextrema=True, showmedians=False) -@image_comparison(['violinplot_horiz_showall.png']) +@image_comparison(['violinplot_horiz_showall.png'], style='mpl20') def test_horiz_violinplot_showall(): ax = plt.axes() # First 9 digits of frac(sqrt(37)) @@ -4145,7 +4148,7 @@ def test_horiz_violinplot_showall(): quantiles=[[0.1, 0.9], [0.2, 0.8], [0.3, 0.7], [0.4, 0.6]]) -@image_comparison(['violinplot_horiz_custompoints_10.png']) +@image_comparison(['violinplot_horiz_custompoints_10.png'], style='mpl20') def test_horiz_violinplot_custompoints_10(): ax = plt.axes() # First 9 digits of frac(sqrt(41)) @@ -4155,7 +4158,7 @@ def test_horiz_violinplot_custompoints_10(): showextrema=False, showmedians=False, points=10) -@image_comparison(['violinplot_horiz_custompoints_200.png']) +@image_comparison(['violinplot_horiz_custompoints_200.png'], style='mpl20') def test_horiz_violinplot_custompoints_200(): ax = plt.axes() # First 9 digits of frac(sqrt(43)) @@ -4464,7 +4467,8 @@ def test_tick_space_size_0(): plt.savefig(b, dpi=80, format='raw') -@image_comparison(['errorbar_basic.png', 'errorbar_mixed.png', 'errorbar_basic.png']) +@image_comparison(['errorbar_basic.png', 'errorbar_mixed.png', 'errorbar_basic.png'], + style='mpl20') def test_errorbar(): # longdouble due to floating point rounding issues with certain # computer chipsets @@ -4601,7 +4605,7 @@ def test_errorbar_shape(): ax.errorbar(x, y, yerr=yerr, xerr=xerr, fmt='o') -@image_comparison(['errorbar_limits.png']) +@image_comparison(['errorbar_limits.png'], style='mpl20') def test_errorbar_limits(): x = np.arange(0.5, 5.5, 0.5) y = np.exp(-x) @@ -4627,7 +4631,7 @@ def test_errorbar_limits(): color='red') # including upper and lower limits - ax.errorbar(x, y+1.5, marker='o', ms=8, xerr=xerr, yerr=yerr, + ax.errorbar(x, y+1.5, marker='o', ms=6, xerr=xerr, yerr=yerr, lolims=lolims, uplims=uplims, ls=ls, color='magenta') # including xlower and xupper limits @@ -4640,7 +4644,7 @@ def test_errorbar_limits(): uplims = np.zeros_like(x) lolims[[6]] = True uplims[[3]] = True - ax.errorbar(x, y+2.1, marker='o', ms=8, xerr=xerr, yerr=yerr, + ax.errorbar(x, y+2.1, marker='o', ms=6, xerr=xerr, yerr=yerr, xlolims=xlolims, xuplims=xuplims, uplims=uplims, lolims=lolims, ls='none', mec='blue', capsize=0, color='cyan') @@ -4851,7 +4855,8 @@ def test_errorbar_masked_negative(fig_test, fig_ref): ax.errorbar([4], [3], yerr=[6], fmt="C0") -@image_comparison(['hist_stacked_stepfilled.png', 'hist_stacked_stepfilled.png']) +@image_comparison(['hist_stacked_stepfilled.png', 'hist_stacked_stepfilled.png'], + style='mpl20') def test_hist_stacked_stepfilled(): # make some data d1 = np.linspace(1, 3, 20) @@ -4865,7 +4870,7 @@ def test_hist_stacked_stepfilled(): ax.hist("x", histtype="stepfilled", stacked=True, data=data) -@image_comparison(['hist_offset.png']) +@image_comparison(['hist_offset.png'], style='mpl20') def test_hist_offset(): # make some data d1 = np.linspace(0, 10, 50) @@ -4885,7 +4890,7 @@ def test_hist_step(): ax.set_xlim(-1, 5) -@image_comparison(['hist_step_horiz.png']) +@image_comparison(['hist_step_horiz.png'], style='mpl20') def test_hist_step_horiz(): # make some data d1 = np.linspace(0, 10, 50) @@ -4894,7 +4899,7 @@ def test_hist_step_horiz(): ax.hist((d1, d2), histtype="step", orientation="horizontal") -@image_comparison(['hist_stacked_weights.png']) +@image_comparison(['hist_stacked_weights.png'], style='mpl20') def test_hist_stacked_weighted(): # make some data d1 = np.linspace(0, 10, 50) @@ -5036,7 +5041,7 @@ def test_stem_polar_baseline(): assert container.baseline.get_path()._interpolation_steps > 100 -@image_comparison(['hist_stacked_stepfilled_alpha.png']) +@image_comparison(['hist_stacked_stepfilled_alpha.png'], style='mpl20') def test_hist_stacked_stepfilled_alpha(): # make some data d1 = np.linspace(1, 3, 20) @@ -5045,7 +5050,7 @@ def test_hist_stacked_stepfilled_alpha(): ax.hist((d1, d2), histtype="stepfilled", stacked=True, alpha=0.5) -@image_comparison(['hist_stacked_step.png']) +@image_comparison(['hist_stacked_step.png'], style='mpl20') def test_hist_stacked_step(): # make some data d1 = np.linspace(1, 3, 20) @@ -5054,7 +5059,7 @@ def test_hist_stacked_step(): ax.hist((d1, d2), histtype="step", stacked=True) -@image_comparison(['hist_stacked_normed.png']) +@image_comparison(['hist_stacked_normed.png'], style='mpl20') def test_hist_stacked_density(): # make some data d1 = np.linspace(1, 3, 20) @@ -5142,7 +5147,7 @@ def test_hist_stacked_step_bottom_geometry(): assert_array_equal(polygon.get_xy(), xy[1]) -@image_comparison(['hist_stacked_bar.png']) +@image_comparison(['hist_stacked_bar.png'], style='mpl20') def test_hist_stacked_bar(): # make some data d = [[100, 100, 100, 100, 200, 320, 450, 80, 20, 600, 310, 800], @@ -5545,7 +5550,7 @@ def test_marker_styles(): marker=marker, markersize=10+y/5, label=marker) -@image_comparison(['rc_markerfill.png'], +@image_comparison(['rc_markerfill.png'], style='mpl20', tol=0 if platform.machine() == 'x86_64' else 0.037) def test_markers_fillstyle_rcparams(): fig, ax = plt.subplots() @@ -5568,7 +5573,7 @@ def test_vertex_markers(): ax.set_ylim(-1, 10) -@image_comparison(['vline_hline_zorder.png', 'errorbar_zorder.png'], +@image_comparison(['vline_hline_zorder.png', 'errorbar_zorder.png'], style='mpl20', tol=0 if platform.machine() == 'x86_64' else 0.026) def test_eb_line_zorder(): x = list(range(10)) @@ -5691,7 +5696,8 @@ def test_axline_args(): plt.draw() -@image_comparison(['vlines_basic.png', 'vlines_with_nan.png', 'vlines_masked.png']) +@image_comparison(['vlines_basic.png', 'vlines_with_nan.png', 'vlines_masked.png'], + style='mpl20') def test_vlines(): # normal x1 = [2, 3, 4, 5, 7] @@ -5737,7 +5743,8 @@ def test_vlines_default(): assert mpl.colors.same_color(lines.get_color(), 'red') -@image_comparison(['hlines_basic.png', 'hlines_with_nan.png', 'hlines_masked.png']) +@image_comparison(['hlines_basic.png', 'hlines_with_nan.png', 'hlines_masked.png'], + style='mpl20') def test_hlines(): # normal y1 = [2, 3, 4, 5, 7] @@ -6485,7 +6492,7 @@ def test_text_labelsize(): # These tolerances could likely go away when numpy 2.0 is the minimum supported # numpy and the images are regenerated. -@image_comparison(['pie_default.png'], tol=0.01) +@image_comparison(['pie_default.png'], style='mpl20', tol=0.01) def test_pie_default(): # The slices will be ordered and plotted counter-clockwise. labels = 'Frogs', 'Hogs', 'Dogs', 'Logs' @@ -6623,7 +6630,7 @@ def test_pie_rotatelabels_true(): plt.axis('equal') -@image_comparison(['pie_no_label.png'], tol=0.01) +@image_comparison(['pie_no_label.png'], style='mpl20', tol=0.01) def test_pie_nolabel_but_legend(): labels = 'Frogs', 'Hogs', 'Dogs', 'Logs' sizes = [15, 30, 45, 10] @@ -6789,8 +6796,8 @@ def test_pie_label_fail(): ax.pie_label(pie, labels) -@image_comparison(['set_get_ticklabels.png'], - tol=0 if platform.machine() == 'x86_64' else 0.025) +@image_comparison(['set_get_ticklabels.png'], style='mpl20', + tol=0 if platform.machine() == 'x86_64' else 0.03) def test_set_get_ticklabels(): # test issue 2246 fig, ax = plt.subplots(2) @@ -6891,7 +6898,7 @@ def test_empty_ticks_fixed_loc(): ax.set_xticklabels([]) -@image_comparison(['retain_tick_visibility.png']) +@image_comparison(['retain_tick_visibility.png'], style='mpl20') def test_retain_tick_visibility(): fig, ax = plt.subplots() plt.plot([0, 1, 2], [0, -1, 4]) @@ -6933,7 +6940,7 @@ def formatter_func(x, pos): assert tick_texts == ["", "", "unit value", "", ""] -@image_comparison(['o_marker_path_snap.png'], savefig_kwarg={'dpi': 72}) +@image_comparison(['o_marker_path_snap.png'], savefig_kwarg={'dpi': 72}, style='mpl20') def test_o_marker_path_snap(): fig, ax = plt.subplots() ax.margins(.1) @@ -7111,7 +7118,7 @@ def test_move_offsetlabel(): assert ax.xaxis.offsetText.get_verticalalignment() == 'bottom' -@image_comparison(['rc_spines.png'], savefig_kwarg={'dpi': 40}) +@image_comparison(['rc_spines.png'], savefig_kwarg={'dpi': 40}, style='mpl20') def test_rc_spines(): rc_dict = { 'axes.spines.left': False, @@ -7122,7 +7129,7 @@ def test_rc_spines(): plt.subplots() # create a figure and axes with the spine properties -@image_comparison(['rc_grid.png'], savefig_kwarg={'dpi': 40}) +@image_comparison(['rc_grid.png'], savefig_kwarg={'dpi': 40}, style='mpl20') def test_rc_grid(): fig = plt.figure() rc_dict0 = { @@ -9160,7 +9167,7 @@ def test_bar_label_location_center(): assert labels[1].get_verticalalignment() == 'center' -@image_comparison(['test_centered_bar_label_nonlinear.svg']) +@image_comparison(['test_centered_bar_label_nonlinear.svg'], style='mpl20') def test_centered_bar_label_nonlinear(): _, ax = plt.subplots() bar_container = ax.barh(['c', 'b', 'a'], [1_000, 5_000, 7_000]) diff --git a/lib/matplotlib/tests/test_backend_pdf.py b/lib/matplotlib/tests/test_backend_pdf.py index dac796336fe9..20776af13307 100644 --- a/lib/matplotlib/tests/test_backend_pdf.py +++ b/lib/matplotlib/tests/test_backend_pdf.py @@ -346,7 +346,7 @@ def test_empty_rasterized(): fig.savefig(io.BytesIO(), format="pdf") -@image_comparison(['kerning.pdf']) +@image_comparison(['kerning.pdf'], style='mpl20') def test_kerning(): fig = plt.figure() s = "AVAVAVAVAVAVAVAV€AAVV" @@ -380,24 +380,24 @@ def test_glyphs_subset(): assert subfont.get_num_glyphs() == nosubfont.get_num_glyphs() -@image_comparison(["multi_font_type3.pdf"]) +@image_comparison(["multi_font_type3.pdf"], style='mpl20') def test_multi_font_type3(): fonts, test_str = _gen_multi_font_text() plt.rc('font', family=fonts, size=16) plt.rc('pdf', fonttype=3) - fig = plt.figure() + fig = plt.figure(figsize=(8, 6)) fig.text(0.5, 0.5, test_str, horizontalalignment='center', verticalalignment='center') -@image_comparison(["multi_font_type42.pdf"]) +@image_comparison(["multi_font_type42.pdf"], style='mpl20') def test_multi_font_type42(): fonts, test_str = _gen_multi_font_text() plt.rc('font', family=fonts, size=16) plt.rc('pdf', fonttype=42) - fig = plt.figure() + fig = plt.figure(figsize=(8, 6)) fig.text(0.5, 0.5, test_str, horizontalalignment='center', verticalalignment='center') @@ -450,14 +450,14 @@ def test_otf_font_smoke(family_name, file_name): fig.savefig(io.BytesIO(), format="pdf") -@image_comparison(["truetype-conversion.pdf"]) +@image_comparison(["truetype-conversion.pdf"], style='mpl20') # mpltest.ttf does not have "l"/"p" glyphs so we get a warning when trying to # get the font extents. def test_truetype_conversion(recwarn): mpl.rcParams['pdf.fonttype'] = 3 fig, ax = plt.subplots() ax.text(0, 0, "ABCDE", - font=Path(__file__).parent / "data/mpltest.ttf", fontsize=80) + font=Path(__file__).parent / "data/mpltest.ttf", fontsize=72) ax.set_xticks([]) ax.set_yticks([]) diff --git a/lib/matplotlib/tests/test_backend_ps.py b/lib/matplotlib/tests/test_backend_ps.py index 5037c15370a5..6eac82678362 100644 --- a/lib/matplotlib/tests/test_backend_ps.py +++ b/lib/matplotlib/tests/test_backend_ps.py @@ -315,24 +315,24 @@ def test_no_duplicate_definition(): assert max(Counter(wds).values()) == 1 -@image_comparison(["multi_font_type3.eps"]) +@image_comparison(["multi_font_type3.eps"], style='mpl20') def test_multi_font_type3(): fonts, test_str = _gen_multi_font_text() plt.rc('font', family=fonts, size=16) plt.rc('ps', fonttype=3) - fig = plt.figure() + fig = plt.figure(figsize=(8, 6)) fig.text(0.5, 0.5, test_str, horizontalalignment='center', verticalalignment='center') -@image_comparison(["multi_font_type42.eps"]) +@image_comparison(["multi_font_type42.eps"], style='mpl20') def test_multi_font_type42(): fonts, test_str = _gen_multi_font_text() plt.rc('font', family=fonts, size=16) plt.rc('ps', fonttype=42) - fig = plt.figure() + fig = plt.figure(figsize=(8, 6)) fig.text(0.5, 0.5, test_str, horizontalalignment='center', verticalalignment='center') diff --git a/lib/matplotlib/tests/test_backend_svg.py b/lib/matplotlib/tests/test_backend_svg.py index a95ed48e12d5..6c540ccebd76 100644 --- a/lib/matplotlib/tests/test_backend_svg.py +++ b/lib/matplotlib/tests/test_backend_svg.py @@ -68,7 +68,7 @@ def test_text_urls(): assert expected in buf -@image_comparison(['bold_font_output.svg']) +@image_comparison(['bold_font_output.svg'], style='mpl20') def test_bold_font_output(): fig, ax = plt.subplots() ax.plot(np.arange(10), np.arange(10)) @@ -527,24 +527,24 @@ def test_svg_metadata(): assert values == metadata['Keywords'] -@image_comparison(["multi_font_aspath.svg"]) +@image_comparison(["multi_font_aspath.svg"], style='mpl20') def test_multi_font_aspath(): fonts, test_str = _gen_multi_font_text() plt.rc('font', family=fonts, size=16) plt.rc('svg', fonttype='path') - fig = plt.figure() + fig = plt.figure(figsize=(8, 6)) fig.text(0.5, 0.5, test_str, horizontalalignment='center', verticalalignment='center') -@image_comparison(["multi_font_astext.svg"]) +@image_comparison(["multi_font_astext.svg"], style='mpl20') def test_multi_font_astext(): fonts, test_str = _gen_multi_font_text() plt.rc('font', family=fonts, size=16) plt.rc('svg', fonttype='none') - fig = plt.figure() + fig = plt.figure(figsize=(8, 6)) fig.text(0.5, 0.5, test_str, horizontalalignment='center', verticalalignment='center') diff --git a/lib/matplotlib/tests/test_bbox_tight.py b/lib/matplotlib/tests/test_bbox_tight.py index 677cdf37dd24..f6d910a7f208 100644 --- a/lib/matplotlib/tests/test_bbox_tight.py +++ b/lib/matplotlib/tests/test_bbox_tight.py @@ -46,7 +46,7 @@ def test_bbox_inches_tight(text_placeholders): @image_comparison(['bbox_inches_tight_suptile_legend'], - savefig_kwarg={'bbox_inches': 'tight'}, + savefig_kwarg={'bbox_inches': 'tight'}, style='mpl20', tol=0 if platform.machine() == 'x86_64' else 0.024) def test_bbox_inches_tight_suptile_legend(): plt.plot(np.arange(10), label='a straight line') @@ -66,7 +66,7 @@ def y_formatter(y, pos): @image_comparison(['bbox_inches_tight_suptile_non_default.png'], - savefig_kwarg={'bbox_inches': 'tight'}, + savefig_kwarg={'bbox_inches': 'tight'}, style='mpl20', tol=0.1) # large tolerance because only testing clipping. def test_bbox_inches_tight_suptitle_non_default(): fig, ax = plt.subplots() @@ -111,7 +111,8 @@ def test_bbox_inches_tight_clipping(): @image_comparison(['bbox_inches_tight_raster'], tol=0.15, # For Ghostscript 10.06+. - remove_text=True, savefig_kwarg={'bbox_inches': 'tight'}) + remove_text=True, savefig_kwarg={'bbox_inches': 'tight'}, + style='mpl20') def test_bbox_inches_tight_raster(): """Test rasterization with tight_layout""" fig, ax = plt.subplots() @@ -168,7 +169,7 @@ def test_noop_tight_bbox(): @image_comparison(['bbox_inches_fixed_aspect.png'], remove_text=True, - savefig_kwarg={'bbox_inches': 'tight'}) + savefig_kwarg={'bbox_inches': 'tight'}, style='mpl20') def test_bbox_inches_fixed_aspect(): with plt.rc_context({'figure.constrained_layout.use': True}): fig, ax = plt.subplots() diff --git a/lib/matplotlib/tests/test_collections.py b/lib/matplotlib/tests/test_collections.py index c0ac4ac28c8b..dc397ffde93e 100644 --- a/lib/matplotlib/tests/test_collections.py +++ b/lib/matplotlib/tests/test_collections.py @@ -66,7 +66,7 @@ def generate_EventCollection_plot(): return ax, coll, props -@image_comparison(['EventCollection_plot__default.png']) +@image_comparison(['EventCollection_plot__default.png'], style='mpl20') def test__EventCollection__get_props(): _, coll, props = generate_EventCollection_plot() # check that the default segments have the correct coordinates @@ -92,7 +92,7 @@ def test__EventCollection__get_props(): np.testing.assert_array_equal(color, props['color']) -@image_comparison(['EventCollection_plot__set_positions.png']) +@image_comparison(['EventCollection_plot__set_positions.png'], style='mpl20') def test__EventCollection__set_positions(): splt, coll, props = generate_EventCollection_plot() new_positions = np.hstack([props['positions'], props['extra_positions']]) @@ -106,7 +106,7 @@ def test__EventCollection__set_positions(): splt.set_xlim(-1, 90) -@image_comparison(['EventCollection_plot__add_positions.png']) +@image_comparison(['EventCollection_plot__add_positions.png'], style='mpl20') def test__EventCollection__add_positions(): splt, coll, props = generate_EventCollection_plot() new_positions = np.hstack([props['positions'], @@ -124,7 +124,7 @@ def test__EventCollection__add_positions(): splt.set_xlim(-1, 35) -@image_comparison(['EventCollection_plot__append_positions.png']) +@image_comparison(['EventCollection_plot__append_positions.png'], style='mpl20') def test__EventCollection__append_positions(): splt, coll, props = generate_EventCollection_plot() new_positions = np.hstack([props['positions'], @@ -140,7 +140,7 @@ def test__EventCollection__append_positions(): splt.set_xlim(-1, 90) -@image_comparison(['EventCollection_plot__extend_positions.png']) +@image_comparison(['EventCollection_plot__extend_positions.png'], style='mpl20') def test__EventCollection__extend_positions(): splt, coll, props = generate_EventCollection_plot() new_positions = np.hstack([props['positions'], @@ -156,7 +156,7 @@ def test__EventCollection__extend_positions(): splt.set_xlim(-1, 90) -@image_comparison(['EventCollection_plot__switch_orientation.png']) +@image_comparison(['EventCollection_plot__switch_orientation.png'], style='mpl20') def test__EventCollection__switch_orientation(): splt, coll, props = generate_EventCollection_plot() new_orientation = 'vertical' @@ -173,7 +173,7 @@ def test__EventCollection__switch_orientation(): splt.set_xlim(0, 2) -@image_comparison(['EventCollection_plot__switch_orientation__2x.png']) +@image_comparison(['EventCollection_plot__switch_orientation__2x.png'], style='mpl20') def test__EventCollection__switch_orientation_2x(): """ Check that calling switch_orientation twice sets the orientation back to @@ -194,7 +194,7 @@ def test__EventCollection__switch_orientation_2x(): splt.set_title('EventCollection: switch_orientation 2x') -@image_comparison(['EventCollection_plot__set_orientation.png']) +@image_comparison(['EventCollection_plot__set_orientation.png'], style='mpl20') def test__EventCollection__set_orientation(): splt, coll, props = generate_EventCollection_plot() new_orientation = 'vertical' @@ -211,7 +211,7 @@ def test__EventCollection__set_orientation(): splt.set_xlim(0, 2) -@image_comparison(['EventCollection_plot__set_linelength.png']) +@image_comparison(['EventCollection_plot__set_linelength.png'], style='mpl20') def test__EventCollection__set_linelength(): splt, coll, props = generate_EventCollection_plot() new_linelength = 15 @@ -226,7 +226,7 @@ def test__EventCollection__set_linelength(): splt.set_ylim(-20, 20) -@image_comparison(['EventCollection_plot__set_lineoffset.png']) +@image_comparison(['EventCollection_plot__set_lineoffset.png'], style='mpl20') def test__EventCollection__set_lineoffset(): splt, coll, props = generate_EventCollection_plot() new_lineoffset = -5. @@ -245,11 +245,12 @@ def test__EventCollection__set_lineoffset(): 'EventCollection_plot__set_linestyle.png', 'EventCollection_plot__set_linestyle.png', 'EventCollection_plot__set_linewidth.png', -]) +], style='mpl20') def test__EventCollection__set_prop(): for prop, value, expected in [ - ('linestyle', 'dashed', [(0, (6.0, 6.0))]), - ('linestyle', (0, (6., 6.)), [(0, (6.0, 6.0))]), + ('linestyle', 'dashed', [(0, [7.4, 3.2])]), + # Dashes are scaled by linewidth. + ('linestyle', (0, (3.7, 1.6)), [(0, [7.4, 3.2])]), ('linewidth', 5, 5), ]: splt, coll, _ = generate_EventCollection_plot() @@ -258,7 +259,7 @@ def test__EventCollection__set_prop(): splt.set_title(f'EventCollection: set_{prop}') -@image_comparison(['EventCollection_plot__set_color.png']) +@image_comparison(['EventCollection_plot__set_color.png'], style='mpl20') def test__EventCollection__set_color(): splt, coll, _ = generate_EventCollection_plot() new_color = np.array([0, 1, 1, 1]) @@ -720,7 +721,7 @@ def test_joinstyle(): assert col.get_joinstyle() == 'miter' -@image_comparison(['cap_and_joinstyle.png']) +@image_comparison(['cap_and_joinstyle.png'], style='mpl20') def test_cap_and_joinstyle_image(): fig, ax = plt.subplots() ax.set_xlim([-0.5, 1.5]) diff --git a/lib/matplotlib/tests/test_colorbar.py b/lib/matplotlib/tests/test_colorbar.py index 2655f5557298..4fd943a3e7a4 100644 --- a/lib/matplotlib/tests/test_colorbar.py +++ b/lib/matplotlib/tests/test_colorbar.py @@ -159,7 +159,7 @@ def test_colorbar_extension_inverted_axis(orientation, extend, expected): 'double_cbar.png', 'cbar_sharing.png', ], - remove_text=True, savefig_kwarg={'dpi': 40}, tol=0.05) + remove_text=True, savefig_kwarg={'dpi': 40}, style='mpl20', tol=0.05) def test_colorbar_positioning(use_gridspec): data = np.arange(1200).reshape(30, 40) levels = [0, 200, 400, 600, 800, 1000, 1200] diff --git a/lib/matplotlib/tests/test_colors.py b/lib/matplotlib/tests/test_colors.py index dcccd92c54cb..1d3868320743 100644 --- a/lib/matplotlib/tests/test_colors.py +++ b/lib/matplotlib/tests/test_colors.py @@ -828,7 +828,7 @@ def _mask_tester(norm_instance, vals): assert_array_equal(masked_array.mask, norm_instance(masked_array).mask) -@image_comparison(['levels_and_colors.png']) +@image_comparison(['levels_and_colors.png'], style='mpl20') def test_cmap_and_norm_from_levels_and_colors(): data = np.linspace(-2, 4, 49).reshape(7, 7) levels = [-1, 2, 2.5, 3] diff --git a/lib/matplotlib/tests/test_dates.py b/lib/matplotlib/tests/test_dates.py index d3f64d73002e..c456e3aca089 100644 --- a/lib/matplotlib/tests/test_dates.py +++ b/lib/matplotlib/tests/test_dates.py @@ -140,7 +140,7 @@ def test_axhline(): mdates._reset_epoch_test_example() -@image_comparison(['date_axhspan.png']) +@image_comparison(['date_axhspan.png'], style='mpl20') def test_date_axhspan(): # test axhspan with date inputs t0 = datetime.datetime(2009, 1, 20) @@ -153,7 +153,7 @@ def test_date_axhspan(): # TODO: tighten tolerance after baseline image is regenerated for text overhaul -@image_comparison(['date_axvspan.png'], tol=0.07) +@image_comparison(['date_axvspan.png'], style='mpl20', tol=0.07) def test_date_axvspan(): # test axvspan with date inputs t0 = datetime.datetime(2000, 1, 20) @@ -165,7 +165,7 @@ def test_date_axvspan(): fig.autofmt_xdate() -@image_comparison(['date_axhline.png']) +@image_comparison(['date_axhline.png'], style='mpl20') def test_date_axhline(): # test axhline with date inputs t0 = datetime.datetime(2009, 1, 20) @@ -178,7 +178,7 @@ def test_date_axhline(): # TODO: tighten tolerance after baseline image is regenerated for text overhaul -@image_comparison(['date_axvline.png'], tol=0.09) +@image_comparison(['date_axvline.png'], style='mpl20', tol=0.09) def test_date_axvline(): # test axvline with date inputs t0 = datetime.datetime(2000, 1, 20) @@ -229,7 +229,7 @@ def wrapper(): # TODO: tighten tolerance after baseline image is regenerated for text overhaul -@image_comparison(['RRuleLocator_bounds.png'], tol=0.07) +@image_comparison(['RRuleLocator_bounds.png'], style='mpl20', tol=0.07) def test_RRuleLocator(): import matplotlib.testing.jpl_units as units units.register() @@ -274,7 +274,7 @@ def test_RRuleLocator_close_minmax(): # TODO: tighten tolerance after baseline image is regenerated for text overhaul -@image_comparison(['DateFormatter_fractionalSeconds.png'], tol=0.11) +@image_comparison(['DateFormatter_fractionalSeconds.png'], style='mpl20', tol=0.11) def test_DateFormatter(): import matplotlib.testing.jpl_units as units units.register() @@ -957,7 +957,7 @@ def _create_auto_date_locator(date1, date2, tz): assert st == expected -@image_comparison(['date_inverted_limit.png']) +@image_comparison(['date_inverted_limit.png'], style='mpl20') def test_date_inverted_limit(): # test ax hline with date inputs t0 = datetime.datetime(2009, 1, 20) diff --git a/lib/matplotlib/tests/test_figure.py b/lib/matplotlib/tests/test_figure.py index c0508a00d9c8..9f002b672b84 100644 --- a/lib/matplotlib/tests/test_figure.py +++ b/lib/matplotlib/tests/test_figure.py @@ -27,7 +27,7 @@ # TODO: tighten tolerance after baseline image is regenerated for text overhaul -@image_comparison(['figure_align_labels'], extensions=['png', 'svg'], +@image_comparison(['figure_align_labels'], extensions=['png', 'svg'], style='mpl20', tol=0.1 if platform.machine() == 'x86_64' else 0.1) def test_align_labels(): fig = plt.figure(layout='tight') @@ -210,8 +210,8 @@ def test_clf_keyword(): assert [t.get_text() for t in fig2.texts] == [] -@image_comparison(['figure_today.png'], - tol=0 if platform.machine() == 'x86_64' else 0.015) +@image_comparison(['figure_today.png'], style='mpl20', + tol=0 if platform.machine() == 'x86_64' else 0.022) def test_figure(): # named figure support fig = plt.figure('today') @@ -226,7 +226,7 @@ def test_figure(): plt.close('tomorrow') -@image_comparison(['figure_legend.png']) +@image_comparison(['figure_legend.png'], style='mpl20') def test_figure_legend(): fig, axs = plt.subplots(2) axs[0].plot([0, 1], [1, 0], label='x', color='g') @@ -324,7 +324,7 @@ def test_add_subplot_invalid(): # TODO: tighten tolerance after baseline image is regenerated for text overhaul -@image_comparison(['figure_suptitle.png'], tol=0.02) +@image_comparison(['figure_suptitle.png'], style='mpl20', tol=0.02) def test_suptitle(): fig, _ = plt.subplots() fig.suptitle('hello', color='r') diff --git a/lib/matplotlib/tests/test_ft2font.py b/lib/matplotlib/tests/test_ft2font.py index a55d1051779b..8b44792a0c2d 100644 --- a/lib/matplotlib/tests/test_ft2font.py +++ b/lib/matplotlib/tests/test_ft2font.py @@ -993,7 +993,7 @@ def test_fallback_missing(recwarn, font_list): assert all([font in recwarn[0].message.args[0] for font in font_list]) -@image_comparison(['last_resort']) +@image_comparison(['last_resort'], style='mpl20') def test_fallback_last_resort(recwarn): fig = plt.figure(figsize=(3, 0.5)) fig.text(.5, .5, "Hello 🙃 World!", size=24, diff --git a/lib/matplotlib/tests/test_image.py b/lib/matplotlib/tests/test_image.py index 649e345b3613..fcac9bacdd26 100644 --- a/lib/matplotlib/tests/test_image.py +++ b/lib/matplotlib/tests/test_image.py @@ -50,7 +50,7 @@ def test_alpha_interp(): @image_comparison(['interp_nearest_vs_none'], tol=3.7, # For Ghostscript 10.06+. - extensions=['pdf', 'svg'], remove_text=True) + extensions=['pdf', 'svg'], remove_text=True, style='mpl20') def test_interp_nearest_vs_none(): """Test the effect of "nearest" and "none" interpolation""" # Setting dpi to something really small makes the difference very diff --git a/lib/matplotlib/tests/test_legend.py b/lib/matplotlib/tests/test_legend.py index 06a9d6cf8b63..4e4f021f2df6 100644 --- a/lib/matplotlib/tests/test_legend.py +++ b/lib/matplotlib/tests/test_legend.py @@ -54,7 +54,7 @@ def test_legend_generator(): ax.legend(handles, labels, loc='upper left') -@image_comparison(['legend_auto1.png'], remove_text=True) +@image_comparison(['legend_auto1.png'], remove_text=True, style='mpl20') def test_legend_auto1(): """Test automatic legend placement""" fig, ax = plt.subplots() @@ -64,7 +64,7 @@ def test_legend_auto1(): ax.legend(loc='best') -@image_comparison(['legend_auto2.png'], remove_text=True) +@image_comparison(['legend_auto2.png'], remove_text=True, style='mpl20') def test_legend_auto2(): """Test automatic legend placement""" fig, ax = plt.subplots() @@ -74,7 +74,7 @@ def test_legend_auto2(): ax.legend([b1[0], b2[0]], ['up', 'down'], loc='best') -@image_comparison(['legend_auto3.png']) +@image_comparison(['legend_auto3.png'], style='mpl20') def test_legend_auto3(): """Test automatic legend placement""" fig, ax = plt.subplots() @@ -140,7 +140,7 @@ def test_legend_auto5(): assert_allclose(leg_bboxes[1].bounds, leg_bboxes[0].bounds) -@image_comparison(['legend_various_labels.png'], remove_text=True) +@image_comparison(['legend_various_labels.png'], remove_text=True, style='mpl20') def test_various_labels(): # tests all sorts of label types fig = plt.figure() @@ -151,8 +151,8 @@ def test_various_labels(): ax.legend(numpoints=1, loc='best') -@image_comparison(['legend_labels_first.png'], remove_text=True, - tol=0 if platform.machine() == 'x86_64' else 0.013) +@image_comparison(['legend_labels_first.png'], remove_text=True, style='mpl20', + tol=0 if platform.machine() == 'x86_64' else 0.015) def test_labels_first(): # test labels to left of markers fig, ax = plt.subplots() @@ -162,8 +162,8 @@ def test_labels_first(): ax.legend(loc='best', markerfirst=False) -@image_comparison(['legend_multiple_keys.png'], remove_text=True, - tol=0 if platform.machine() == 'x86_64' else 0.013) +@image_comparison(['legend_multiple_keys.png'], remove_text=True, style='mpl20', + tol=0 if platform.machine() == 'x86_64' else 0.033) def test_multiple_keys(): # test legend entries with multiple keys fig, ax = plt.subplots() @@ -176,16 +176,18 @@ def test_multiple_keys(): (p2, p1): HandlerTuple(ndivide=None, pad=0)}) -@image_comparison(['rgba_alpha.png'], remove_text=True, +@image_comparison(['rgba_alpha.png'], remove_text=True, style='mpl20', tol=0 if platform.machine() == 'x86_64' else 0.03) def test_alpha_rgba(): + # This rcParam would override the explicit setting below, so disable it. + plt.rcParams['legend.framealpha'] = None fig, ax = plt.subplots() ax.plot(range(10), lw=5) leg = plt.legend(['Longlabel that will go away'], loc='center') leg.legendPatch.set_facecolor([1, 0, 0, 0.5]) -@image_comparison(['rcparam_alpha.png'], remove_text=True, +@image_comparison(['rcparam_alpha.png'], remove_text=True, style='mpl20', tol=0 if platform.machine() == 'x86_64' else 0.03) def test_alpha_rcparam(): fig, ax = plt.subplots() @@ -199,7 +201,7 @@ def test_alpha_rcparam(): leg.legendPatch.set_facecolor([1, 0, 0, 0.5]) -@image_comparison(['fancy.png'], remove_text=True, tol=0.05) +@image_comparison(['fancy.png'], remove_text=True, style='mpl20', tol=0.05) def test_fancy(): # Tolerance caused by changing default shadow "shade" from 0.3 to 1 - 0.7 = # 0.30000000000000004 @@ -213,18 +215,20 @@ def test_fancy(): ncols=2, shadow=True, title="My legend", numpoints=1) -@image_comparison(['framealpha'], remove_text=True, +@image_comparison(['framealpha'], remove_text=True, style='mpl20', tol=0 if platform.machine() == 'x86_64' else 0.024) def test_framealpha(): x = np.linspace(1, 100, 100) y = x plt.plot(x, y, label='mylabel', lw=10) - plt.legend(framealpha=0.5) + plt.legend(framealpha=0.5, loc='upper right') -@image_comparison(['scatter_rc3.png', 'scatter_rc1.png'], remove_text=True) +@image_comparison(['scatter_rc3.png', 'scatter_rc1.png'], remove_text=True, + style='mpl20') def test_rc(): # using subplot triggers some offsetbox functionality untested elsewhere + mpl.rcParams['legend.scatterpoints'] = 3 plt.figure() ax = plt.subplot(121) ax.scatter(np.arange(10), np.arange(10, 0, -1), label='three') @@ -239,7 +243,7 @@ def test_rc(): title="My legend") -@image_comparison(['legend_expand.png'], remove_text=True) +@image_comparison(['legend_expand.png'], remove_text=True, style='mpl20') def test_legend_expand(): """Test expand mode""" legend_modes = [None, "expand"] @@ -525,7 +529,7 @@ def test_figure_legend_outside(): rtol=1e-4) -@image_comparison(['legend_stackplot.png'], +@image_comparison(['legend_stackplot.png'], style='mpl20', tol=0 if platform.machine() == 'x86_64' else 0.031) def test_legend_stackplot(): """Test legend for PolyCollection using stackplot.""" @@ -584,7 +588,7 @@ def test_legend_repeatcheckok(): assert len(lab) == 2 -@image_comparison(['not_covering_scatter.png']) +@image_comparison(['not_covering_scatter.png'], style='mpl20') def test_not_covering_scatter(): colors = ['b', 'g', 'r'] @@ -596,7 +600,7 @@ def test_not_covering_scatter(): plt.gca().set_ylim(-0.5, 2.2) -@image_comparison(['not_covering_scatter_transform.png']) +@image_comparison(['not_covering_scatter_transform.png'], style='mpl20') def test_not_covering_scatter_transform(): # Offsets point to top left, the default auto position offset = mtransforms.Affine2D().translate(-20, 20) diff --git a/lib/matplotlib/tests/test_patches.py b/lib/matplotlib/tests/test_patches.py index 80dcc43894c4..12a12cf3e90d 100644 --- a/lib/matplotlib/tests/test_patches.py +++ b/lib/matplotlib/tests/test_patches.py @@ -241,7 +241,7 @@ def test_negative_rect(): assert_array_equal(np.roll(neg_vertices, 2, 0), pos_vertices) -@image_comparison(['clip_to_bbox.png']) +@image_comparison(['clip_to_bbox.png'], style='mpl20') def test_clip_to_bbox(): fig, ax = plt.subplots() ax.set_xlim([-18, 20]) @@ -550,7 +550,7 @@ def test_multi_color_hatch(): ax.add_patch(r) -@image_comparison(['units_rectangle.png']) +@image_comparison(['units_rectangle.png'], style='mpl20') def test_units_rectangle(): import matplotlib.testing.jpl_units as U U.register() @@ -813,7 +813,7 @@ def test_boxstyle_errors(fmt, match): BoxStyle(fmt) -@image_comparison(['annulus.png']) +@image_comparison(['annulus.png'], style='mpl20') def test_annulus(): fig, ax = plt.subplots() @@ -825,7 +825,7 @@ def test_annulus(): ax.set_aspect('equal') -@image_comparison(['annulus.png']) +@image_comparison(['annulus.png'], style='mpl20') def test_annulus_setters(): fig, ax = plt.subplots() @@ -846,7 +846,7 @@ def test_annulus_setters(): ell.angle = 45 -@image_comparison(['annulus.png']) +@image_comparison(['annulus.png'], style='mpl20') def test_annulus_setters2(): fig, ax = plt.subplots() diff --git a/lib/matplotlib/tests/test_patheffects.py b/lib/matplotlib/tests/test_patheffects.py index 0b99a954afb3..05110d5cc1cf 100644 --- a/lib/matplotlib/tests/test_patheffects.py +++ b/lib/matplotlib/tests/test_patheffects.py @@ -11,7 +11,7 @@ from matplotlib.patheffects import PathEffectRenderer -@image_comparison(['patheffect1'], remove_text=True) +@image_comparison(['patheffect1'], remove_text=True, style='mpl20') def test_patheffect1(): ax1 = plt.subplot() ax1.imshow([[1, 2], [2, 3]]) @@ -45,9 +45,10 @@ def test_patheffect2(): foreground="w")]) -@image_comparison(['patheffect3'], +@image_comparison(['patheffect3'], style='mpl20', tol=0 if platform.machine() == 'x86_64' else 0.019) def test_patheffect3(): + plt.figure(figsize=(8, 6)) p1, = plt.plot([1, 3, 5, 4, 3], 'o-b', lw=4) p1.set_path_effects([path_effects.SimpleLineShadow(), path_effects.Normal()]) @@ -74,7 +75,7 @@ def test_patheffect3(): t.set_path_effects(pe) -@image_comparison(['stroked_text.png']) +@image_comparison(['stroked_text.png'], style='mpl20') def test_patheffects_stroked_text(): text_chunks = [ 'A B C D E F G H I J K L', @@ -87,7 +88,7 @@ def test_patheffects_stroked_text(): ] font_size = 50 - ax = plt.axes((0, 0, 1, 1)) + ax = plt.figure(figsize=(8, 6)).add_axes((0, 0, 1, 1)) for i, chunk in enumerate(text_chunks): text = ax.text(x=0.01, y=(0.9 - i * 0.13), s=chunk, fontdict={'ha': 'left', 'va': 'center', @@ -186,7 +187,7 @@ def test_tickedstroke(text_placeholders): ax3.set_ylim(0, 4) -@image_comparison(['spaces_and_newlines.png'], remove_text=True) +@image_comparison(['spaces_and_newlines.png'], remove_text=True, style='mpl20') def test_patheffects_spaces_and_newlines(): ax = plt.subplot() s1 = " " diff --git a/lib/matplotlib/tests/test_polar.py b/lib/matplotlib/tests/test_polar.py index 63d5c45308f1..efc9f52e7586 100644 --- a/lib/matplotlib/tests/test_polar.py +++ b/lib/matplotlib/tests/test_polar.py @@ -72,7 +72,7 @@ def test_polar_coord_annotations(): ax.set_ylim(-20, 20) -@image_comparison(['polar_alignment.png']) +@image_comparison(['polar_alignment.png'], style='mpl20') def test_polar_alignment(): # Test changing the vertical/horizontal alignment of a polar graph. angles = np.arange(0, 360, 90) diff --git a/lib/matplotlib/tests/test_quiver.py b/lib/matplotlib/tests/test_quiver.py index ef4d7a0598eb..4784a7e4dc42 100644 --- a/lib/matplotlib/tests/test_quiver.py +++ b/lib/matplotlib/tests/test_quiver.py @@ -101,16 +101,16 @@ def test_zero_headlength(): fig.canvas.draw() # Check that no warning is emitted. -@image_comparison(['quiver_animated_test_image.png']) +@image_comparison(['quiver_animated_test_image.png'], style='mpl20') def test_quiver_animate(): # Tests fix for #2616 fig, ax = plt.subplots() Q = draw_quiver(ax, animated=True) - ax.quiverkey(Q, 0.5, 0.92, 2, r'$2 \frac{m}{s}$', + ax.quiverkey(Q, 0.5, 0.88, 2, r'$2 \frac{m}{s}$', labelpos='W', fontproperties={'weight': 'bold'}) -@image_comparison(['quiver_with_key_test_image.png']) +@image_comparison(['quiver_with_key_test_image.png'], style='mpl20') def test_quiver_with_key(): fig, ax = plt.subplots() ax.margins(0.1) @@ -138,7 +138,7 @@ def test_quiver_copy(): assert q0.V[0] == 2.0 -@image_comparison(['quiver_key_pivot.png'], remove_text=True) +@image_comparison(['quiver_key_pivot.png'], remove_text=True, style='mpl20') def test_quiver_key_pivot(): fig, ax = plt.subplots() diff --git a/lib/matplotlib/tests/test_simplification.py b/lib/matplotlib/tests/test_simplification.py index 98d3728b1d34..6b2e5b4cd301 100644 --- a/lib/matplotlib/tests/test_simplification.py +++ b/lib/matplotlib/tests/test_simplification.py @@ -493,7 +493,7 @@ def test_para_equal_perp(): ax.plot(x + 1, y + 1, 'ro') -@image_comparison(['clipping_with_nans']) +@image_comparison(['clipping_with_nans'], style='mpl20') def test_clipping_with_nans(): x = np.linspace(0, 3.14 * 2, 3000) y = np.sin(x) diff --git a/lib/matplotlib/tests/test_spines.py b/lib/matplotlib/tests/test_spines.py index 5aecf6c2ad55..4945c53d904d 100644 --- a/lib/matplotlib/tests/test_spines.py +++ b/lib/matplotlib/tests/test_spines.py @@ -55,7 +55,7 @@ def set_val(self, val): spines['top':] -@image_comparison(['spines_axes_positions.png']) +@image_comparison(['spines_axes_positions.png'], style='mpl20') def test_spines_axes_positions(): # SF bug 2852168 fig = plt.figure() @@ -72,7 +72,7 @@ def test_spines_axes_positions(): ax.spines.bottom.set_color('none') -@image_comparison(['spines_data_positions.png']) +@image_comparison(['spines_data_positions.png'], style='mpl20') def test_spines_data_positions(): fig, ax = plt.subplots() ax.spines.left.set_position(('data', -1.5)) @@ -81,6 +81,8 @@ def test_spines_data_positions(): ax.spines.bottom.set_position('zero') ax.set_xlim([-2, 2]) ax.set_ylim([-2, 2]) + ax.xaxis.set_ticks_position('both') + ax.yaxis.set_ticks_position('both') @check_figures_equal() diff --git a/lib/matplotlib/tests/test_subplots.py b/lib/matplotlib/tests/test_subplots.py index 0f00a88aa72d..ed07b0226bc8 100644 --- a/lib/matplotlib/tests/test_subplots.py +++ b/lib/matplotlib/tests/test_subplots.py @@ -180,11 +180,11 @@ def test_exceptions(): plt.subplots(2, 2, sharey='blah') -@image_comparison(['subplots_offset_text.png'], +@image_comparison(['subplots_offset_text.png'], style='mpl20', tol=0 if platform.machine() == 'x86_64' else 0.028) def test_subplots_offsettext(): x = np.arange(0, 1e10, 1e9) - y = np.arange(0, 100, 10)+1e4 + y = np.arange(0, 100, 10)+1e5 fig, axs = plt.subplots(2, 2, sharex='col', sharey='all') axs[0, 0].plot(x, x) axs[1, 0].plot(x, x) diff --git a/lib/matplotlib/tests/test_table.py b/lib/matplotlib/tests/test_table.py index 43b8702737a6..304e69322f81 100644 --- a/lib/matplotlib/tests/test_table.py +++ b/lib/matplotlib/tests/test_table.py @@ -17,7 +17,7 @@ def test_non_square(): plt.table(cellColours=cellcolors) -@image_comparison(['table_zorder.png'], remove_text=True) +@image_comparison(['table_zorder.png'], remove_text=True, style='mpl20') def test_zorder(): data = [[66386, 174296], [58230, 381139]] @@ -50,7 +50,7 @@ def test_zorder(): plt.yticks([]) -@image_comparison(['table_labels.png']) +@image_comparison(['table_labels.png'], style='mpl20') def test_label_colours(): dim = 3 @@ -123,7 +123,7 @@ def test_customcell(): assert c == code -@image_comparison(['table_auto_column.png']) +@image_comparison(['table_auto_column.png'], style='mpl20') def test_auto_column(): fig, (ax1, ax2, ax3, ax4) = plt.subplots(4, 1) diff --git a/lib/matplotlib/tests/test_text.py b/lib/matplotlib/tests/test_text.py index 2027e863a7cf..7b2afcf19791 100644 --- a/lib/matplotlib/tests/test_text.py +++ b/lib/matplotlib/tests/test_text.py @@ -26,7 +26,7 @@ pyparsing_version = parse_version(pyparsing.__version__) -@image_comparison(['font_styles']) +@image_comparison(['font_styles'], style='mpl20') def test_font_styles(): def find_matplotlib_font(**kw): @@ -115,7 +115,7 @@ def find_matplotlib_font(**kw): ax.set_yticks([]) -@image_comparison(['complex'], extensions=['png', 'pdf', 'svg', 'eps']) +@image_comparison(['complex'], extensions=['png', 'pdf', 'svg', 'eps'], style='mpl20') def test_complex_shaping(): # Raqm is Arabic for writing; note that because Arabic is RTL, the characters here # may seem to be in a different order than expected, but libraqm will order them @@ -135,7 +135,7 @@ def test_complex_shaping(): family=['cmr10', 'DejaVu Sans Display', 'DejaVu Sans']) -@image_comparison(['multiline']) +@image_comparison(['multiline'], style='mpl20') def test_multiline(): plt.figure() ax = plt.subplot(1, 1, 1) @@ -229,9 +229,9 @@ def test_antialiasing(): # TODO: tighten tolerance after baseline image is regenerated for text overhaul -@image_comparison(['text_contains.png'], tol=0.05) +@image_comparison(['text_contains.png'], style='mpl20', tol=0.05) def test_contains(): - fig = plt.figure() + fig = plt.figure(figsize=(8, 6)) ax = plt.axes() mevent = MouseEvent('button_press_event', fig.canvas, 0.5, 0.5, 1, None) @@ -287,7 +287,7 @@ def test_annotate_errors(err, xycoords, match): fig.canvas.draw() -@image_comparison(['titles']) +@image_comparison(['titles'], style='mpl20') def test_titles(): # left and right side titles plt.figure() @@ -339,7 +339,7 @@ def test_rotation_mode_anchor(): verticalalignment='center_baseline') -@image_comparison(['axes_titles.png']) +@image_comparison(['axes_titles.png'], style='mpl20') def test_axes_titles(): # Related to issue #3327 plt.figure() @@ -465,14 +465,14 @@ def test_null_rotation_with_rotation_mode(ha, va): t1.get_window_extent(fig.canvas.renderer).get_points()) -@image_comparison(['text_bboxclip']) +@image_comparison(['text_bboxclip'], style='mpl20') def test_bbox_clipping(): plt.text(0.9, 0.2, 'Is bbox clipped?', backgroundcolor='r', clip_on=True) t = plt.text(0.9, 0.5, 'Is fancy bbox clipped?', clip_on=True) t.set_bbox({"boxstyle": "round, pad=0.1"}) -@image_comparison(['annotation_negative_ax_coords.png']) +@image_comparison(['annotation_negative_ax_coords.png'], style='mpl20') def test_annotation_negative_ax_coords(): fig, ax = plt.subplots() @@ -500,31 +500,31 @@ def test_annotation_negative_ax_coords(): va='top') -@image_comparison(['annotation_negative_fig_coords.png']) +@image_comparison(['annotation_negative_fig_coords.png'], style='mpl20') def test_annotation_negative_fig_coords(): fig, ax = plt.subplots() ax.annotate('+ pts', - xytext=[10, 120], textcoords='figure points', - xy=[10, 120], xycoords='figure points', fontsize=32) + xytext=[10, 250], textcoords='figure points', + xy=[10, 250], xycoords='figure points', fontsize=32) ax.annotate('- pts', - xytext=[-10, 180], textcoords='figure points', - xy=[-10, 180], xycoords='figure points', fontsize=32, + xytext=[-10, 310], textcoords='figure points', + xy=[-10, 310], xycoords='figure points', fontsize=32, va='top') ax.annotate('+ frac', - xytext=[0.05, 0.55], textcoords='figure fraction', - xy=[0.05, 0.55], xycoords='figure fraction', fontsize=32) + xytext=[0.05, 0.5], textcoords='figure fraction', + xy=[0.05, 0.5], xycoords='figure fraction', fontsize=32) ax.annotate('- frac', - xytext=[-0.05, 0.5], textcoords='figure fraction', - xy=[-0.05, 0.5], xycoords='figure fraction', fontsize=32, + xytext=[-0.05, 0.45], textcoords='figure fraction', + xy=[-0.05, 0.45], xycoords='figure fraction', fontsize=32, va='top') ax.annotate('+ pixels', xytext=[50, 50], textcoords='figure pixels', xy=[50, 50], xycoords='figure pixels', fontsize=32) ax.annotate('- pixels', - xytext=[-50, 100], textcoords='figure pixels', - xy=[-50, 100], xycoords='figure pixels', fontsize=32, + xytext=[-50, 150], textcoords='figure pixels', + xy=[-50, 150], xycoords='figure pixels', fontsize=32, va='top') @@ -551,7 +551,7 @@ def test_text_stale(): assert not fig.stale -@image_comparison(['agg_text_clip.png']) +@image_comparison(['agg_text_clip.png'], style='mpl20') def test_agg_text_clip(): np.random.seed(1) fig, (ax1, ax2) = plt.subplots(2) @@ -569,7 +569,7 @@ def test_text_size_binding(): assert sz1 == fp.get_size_in_points() -@image_comparison(['font_scaling.pdf']) +@image_comparison(['font_scaling.pdf'], style='mpl20') def test_font_scaling(): mpl.rcParams['pdf.fonttype'] = 42 fig, ax = plt.subplots(figsize=(6.4, 12.4)) @@ -1142,9 +1142,9 @@ def test_empty_annotation_get_window_extent(): # TODO: tighten tolerance after baseline image is regenerated for text overhaul -@image_comparison(['basictext_wrap.png'], tol=0.3) +@image_comparison(['basictext_wrap.png'], style='mpl20', tol=0.3) def test_basic_wrap(): - fig = plt.figure() + fig = plt.figure(figsize=(8, 6)) plt.axis([0, 10, 0, 10]) t = "This is a really long string that I'd rather have wrapped so that" \ " it doesn't go outside of the figure, but if it's long enough it" \ @@ -1159,9 +1159,9 @@ def test_basic_wrap(): # TODO: tighten tolerance after baseline image is regenerated for text overhaul -@image_comparison(['fonttext_wrap.png'], tol=0.3) +@image_comparison(['fonttext_wrap.png'], style='mpl20', tol=0.3) def test_font_wrap(): - fig = plt.figure() + fig = plt.figure(figsize=(8, 6)) plt.axis([0, 10, 0, 10]) t = "This is a really long string that I'd rather have wrapped so that" \ " it doesn't go outside of the figure, but if it's long enough it" \ diff --git a/lib/matplotlib/tests/test_triangulation.py b/lib/matplotlib/tests/test_triangulation.py index ae065a231fd9..c9187915b5a2 100644 --- a/lib/matplotlib/tests/test_triangulation.py +++ b/lib/matplotlib/tests/test_triangulation.py @@ -232,7 +232,7 @@ def tris_contain_point(triang, xy): triang = mtri.Triangulation(tri_points[1:, 0], tri_points[1:, 1]) -@image_comparison(['tripcolor1.png']) +@image_comparison(['tripcolor1.png'], style='mpl20') def test_tripcolor(): x = np.asarray([0, 0.5, 1, 0, 0.5, 1, 0, 0.5, 1, 0.75]) y = np.asarray([0, 0, 0, 0.5, 0.5, 0.5, 1, 1, 1, 0.75]) diff --git a/lib/matplotlib/tests/test_usetex.py b/lib/matplotlib/tests/test_usetex.py index 78d9fd6cc948..440716db2a66 100644 --- a/lib/matplotlib/tests/test_usetex.py +++ b/lib/matplotlib/tests/test_usetex.py @@ -66,7 +66,7 @@ def test_mathdefault(): fig.canvas.draw() -@image_comparison(['eqnarray.png']) +@image_comparison(['eqnarray.png'], style='mpl20') def test_multiline_eqnarray(): text = ( r'\begin{eqnarray*}' 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 3ee8e36ecedc..fb46dcb1900b 100644 --- a/lib/mpl_toolkits/axes_grid1/tests/test_axes_grid1.py +++ b/lib/mpl_toolkits/axes_grid1/tests/test_axes_grid1.py @@ -61,16 +61,14 @@ def test_divider_append_axes(): assert bboxes["top"].x1 == bboxes["main"].x1 == bboxes["bottom"].x1 -# Update style when regenerating the test image -@image_comparison(['twin_axes_empty_and_removed.png'], tol=1, - style=('classic', '_classic_test_patch')) +@image_comparison(['twin_axes_empty_and_removed.png'], tol=1, style='mpl20') def test_twin_axes_empty_and_removed(): # Purely cosmetic font changes (avoid overlap) - mpl.rcParams.update( - {"font.size": 8, "xtick.labelsize": 8, "ytick.labelsize": 8}) + mpl.rcParams.update({"font.size": 8, "xtick.labelsize": 8, "ytick.labelsize": 8}) generators = ["twinx", "twiny", "twin"] modifiers = ["", "host invisible", "twin removed", "twin invisible", "twin removed\nhost invisible"] + plt.figure(figsize=(8, 6)) # Unmodified host subplot at the beginning for reference h = host_subplot(len(modifiers)+1, len(generators), 2) h.text(0.5, 0.5, "host_subplot", @@ -343,10 +341,8 @@ def test_fill_facecolor(): mark_inset(ax[3], axins, loc1=2, loc2=4, fc="g", ec="0.5", fill=False) -# Update style when regenerating the test image -@image_comparison(['zoomed_axes.png', 'inverted_zoomed_axes.png'], - style=('classic', '_classic_test_patch'), - tol=0 if platform.machine() == 'x86_64' else 0.02) +@image_comparison(['zoomed_axes.png', 'inverted_zoomed_axes.png'], style='mpl20', + tol=0 if platform.machine() == 'x86_64' else 0.03) def test_zooming_with_inverted_axes(): fig, ax = plt.subplots() ax.plot([1, 2, 3], [1, 2, 3]) @@ -361,10 +357,9 @@ def test_zooming_with_inverted_axes(): inset_ax.axis([1.4, 1.1, 1.4, 1.1]) -# Update style when regenerating the test image @image_comparison(['anchored_direction_arrows.png'], tol=0 if platform.machine() == 'x86_64' else 0.01, - style=('classic', '_classic_test_patch')) + style='mpl20') def test_anchored_direction_arrows(): fig, ax = plt.subplots() ax.imshow(np.zeros((10, 10)), interpolation='nearest') @@ -373,9 +368,7 @@ def test_anchored_direction_arrows(): ax.add_artist(simple_arrow) -# Update style when regenerating the test image -@image_comparison(['anchored_direction_arrows_many_args.png'], - style=('classic', '_classic_test_patch')) +@image_comparison(['anchored_direction_arrows_many_args.png'], style='mpl20') def test_anchored_direction_arrows_many_args(): fig, ax = plt.subplots() ax.imshow(np.ones((10, 10)))