Skip to content

Commit a5f5af3

Browse files
authored
Merge pull request #24669 from oscargus/imagetestdocs
Doc: clarify preferred image comparison test settings
2 parents 8f5a415 + d833b13 commit a5f5af3

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

doc/devel/testing.rst

+7-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ tests it::
109109
import matplotlib.pyplot as plt
110110

111111
@image_comparison(baseline_images=['line_dashes'], remove_text=True,
112-
extensions=['png'])
112+
extensions=['png'], style='mpl20')
113113
def test_line_dashes():
114114
fig, ax = plt.subplots()
115115
ax.plot(range(10), linestyle=(0, (3, 3)), lw=5)
@@ -130,6 +130,12 @@ images on the figures using two different methods (the tested method and the
130130
baseline method). The decorator will arrange for setting up the figures and
131131
then collect the drawn results and compare them.
132132

133+
It is preferred that new tests use ``style='mpl20'`` as this leads to smaller
134+
figures and reflects the newer look of default Matplotlib plots. Also, if the
135+
texts (labels, tick labels, etc) are not really part of what is tested, use
136+
``remove_text=True`` as this will lead to smaller figures and reduce possible
137+
issues with font mismatch on different platforms.
138+
133139
See the documentation of `~matplotlib.testing.decorators.image_comparison` and
134140
`~matplotlib.testing.decorators.check_figures_equal` for additional information
135141
about their use.

0 commit comments

Comments
 (0)