Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2540eb0

Browse files
committed
fixed code for figures equal docs in testing
1 parent 7ccfd38 commit 2540eb0

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

doc/devel/testing.rst

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -182,17 +182,28 @@ circle: plotting a circle using a `matplotlib.patches.Circle` patch
182182
vs plotting the circle using the parametric equation of a circle ::
183183

184184
from matplotlib.testing.decorators import check_figures_equal
185-
import matplotib.patches as mpatches
185+
import matplotlib.patches as mpatches
186186
import matplotlib.pyplot as plt
187187
import numpy as np
188188

189-
@check_figures_equal(extensions=['png'], tol=100)
189+
@check_figures_equal()
190190
def test_parametric_circle_plot(fig_test, fig_ref):
191-
red_circle_ref = mpatches.Circle((0, 0), 0.2, color='r', clip_on=False)
192-
fig_ref.add_artist(red_circle_ref)
193-
theta = np.linspace(0, 2 * np.pi, 150)
191+
192+
xo, yo= (.5, .5)
194193
radius = 0.4
195-
fig_test.plot(radius * np.cos(theta), radius * np.sin(theta), color='r')
194+
195+
ax_test = fig_test.subplots()
196+
theta = np.linspace(0, 2 * np.pi, 150)
197+
l, = ax_test.plot(xo + (radius * np.cos(theta)),
198+
yo + (radius * np.sin(theta)), c='r')
199+
200+
ax_ref = fig_ref.subplots()
201+
red_circle_ref = mpatches.Circle((xo, yo), radius, ec='r', fc='none',
202+
lw=l.get_linewidth())
203+
ax_ref.add_artist(red_circle_ref)
204+
205+
for ax in [ax_ref, ax_test]:
206+
ax.set(xlim=(0,1), ylim=(0,1), aspect='equal')
196207

197208
Both comparison decorators have a tolerance argument ``tol`` that is used to specify the
198209
tolerance for difference in color value between the two images, where 255 is the maximal

0 commit comments

Comments
 (0)