Skip to content

Close figs #96

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/matplotlib/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ def _check_unsampled_image(self, renderer):
if renderer.option_scale_image():
return True
else:
warnings.warn("The backend (%s) does not support interpolation='none'. The image will be interpolated with 'nearest` mode." % (str(type(renderer))))
warnings.warn("The backend (%s) does not support interpolation='none'. The image will be interpolated with 'nearest` mode." % renderer.__class__)

return False

Expand Down
28 changes: 28 additions & 0 deletions lib/matplotlib/tests/test_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def test_formatter_ticker():
ax.set_xlabel( "x-label 005" )
ax.autoscale_view()
fig.savefig( 'formatter_ticker_005' )
plt.close()

@image_comparison(baseline_images=['offset_points'])
def test_basic_annotate():
Expand All @@ -58,6 +59,7 @@ def test_basic_annotate():
xytext=(3, 3), textcoords='offset points' )

fig.savefig( 'offset_points' )
plt.close()

@image_comparison(baseline_images=['polar_axes'])
def test_polar_annotations():
Expand Down Expand Up @@ -92,6 +94,7 @@ def test_polar_annotations():
)

fig.savefig( 'polar_axes' )
plt.close()

#--------------------------------------------------------------------
@image_comparison(baseline_images=['polar_coords'])
Expand Down Expand Up @@ -123,6 +126,7 @@ def test_polar_coord_annotations():
ax.set_xlim( -20, 20 )
ax.set_ylim( -20, 20 )
fig.savefig( 'polar_coords' )
plt.close()

@image_comparison(baseline_images=['fill_units'])
def test_fill_units():
Expand Down Expand Up @@ -164,6 +168,7 @@ def test_fill_units():

fig.autofmt_xdate()
fig.savefig( 'fill_units' )
plt.close()

@image_comparison(baseline_images=['single_point'])
def test_single_point():
Expand All @@ -175,6 +180,7 @@ def test_single_point():
plt.plot( [1], [1], 'o' )

fig.savefig( 'single_point' )
plt.close()

@image_comparison(baseline_images=['single_date'])
def test_single_date():
Expand All @@ -189,6 +195,7 @@ def test_single_date():
plt.plot( time1, data1, 'o', color='r' )

fig.savefig( 'single_date' )
plt.close()

@image_comparison(baseline_images=['shaped_data'])
def test_shaped_data():
Expand Down Expand Up @@ -233,6 +240,7 @@ def test_shaped_data():
plt.plot( xdata[:,1], xdata[1,:], 'o' )

fig.savefig( 'shaped_data' )
plt.close()

@image_comparison(baseline_images=['const_xy'])
def test_const_xy():
Expand All @@ -248,6 +256,7 @@ def test_const_xy():
plt.plot( np.ones( (10,) ), np.ones( (10,) ), 'o' )

fig.savefig( 'const_xy' )
plt.close()

@image_comparison(baseline_images=['polar_wrap_180',
'polar_wrap_360',
Expand All @@ -264,6 +273,7 @@ def test_polar_wrap():
plt.rgrids( [0.05, 0.1, 0.15, 0.2, 0.25, 0.3] )

fig.savefig( 'polar_wrap_180' )
plt.close()

fig = plt.figure()

Expand All @@ -275,6 +285,7 @@ def test_polar_wrap():
plt.rgrids( [0.05, 0.1, 0.15, 0.2, 0.25, 0.3] )

fig.savefig( 'polar_wrap_360' )
plt.close()

@image_comparison(baseline_images=['polar_units'])
def test_polar_units():
Expand Down Expand Up @@ -305,6 +316,7 @@ def test_polar_units():
y1 = [ y*km for y in y1 ]
plt.polar( x2, y1, color = "blue", thetaunits="rad", runits="km" )
assert_true( isinstance(plt.gca().get_xaxis().get_major_formatter(), units.UnitDblFormatter) )
plt.close()


@image_comparison(baseline_images=['polar_rmin'])
Expand All @@ -319,6 +331,7 @@ def test_polar_rmin():
ax.set_rmin(0.5)

fig.savefig('polar_rmin')
plt.close()

@image_comparison(baseline_images=['axvspan_epoch'])
def test_axvspan_epoch():
Expand All @@ -340,6 +353,7 @@ def test_axvspan_epoch():
ax.set_xlim( t0 - 5.0*dt, tf + 5.0*dt )

fig.savefig( 'axvspan_epoch' )
plt.close()

@image_comparison(baseline_images=['axhspan_epoch'])
def test_axhspan_epoch():
Expand All @@ -361,6 +375,7 @@ def test_axhspan_epoch():
ax.set_ylim( t0 - 5.0*dt, tf + 5.0*dt )

fig.savefig( 'axhspan_epoch' )
plt.close()


@image_comparison(baseline_images=['hexbin_extent'])
Expand All @@ -375,6 +390,7 @@ def test_hexbin_extent():

ax.hexbin(x, y, extent=[.1, .3, .6, .7])
fig.savefig('hexbin_extent')
plt.close()

@image_comparison(baseline_images=['nonfinite_limits'])
def test_nonfinite_limits():
Expand All @@ -385,6 +401,7 @@ def test_nonfinite_limits():
ax = fig.add_subplot(111)
ax.plot(x, y)
fig.savefig('nonfinite_limits')
plt.close()

@image_comparison(baseline_images=['imshow'])
def test_imshow():
Expand All @@ -401,6 +418,7 @@ def test_imshow():

ax.imshow(r)
fig.savefig('imshow')
plt.close()

@image_comparison(baseline_images=['imshow_clip'], tol=1e-2)
def test_imshow_clip():
Expand Down Expand Up @@ -428,6 +446,7 @@ def test_imshow_clip():
#Plot the image clipped by the contour
ax.imshow(r, clip_path=clip_path)
fig.savefig('imshow_clip')
plt.close()

@image_comparison(baseline_images=['polycollection_joinstyle'])
def test_polycollection_joinstyle():
Expand All @@ -446,6 +465,7 @@ def test_polycollection_joinstyle():
ax.set_yticks([])

fig.savefig('polycollection_joinstyle')
plt.close()

@image_comparison(baseline_images=['fill_between_interpolate'], tol=1e-2)
def test_fill_between_interpolate():
Expand All @@ -467,6 +487,7 @@ def test_fill_between_interpolate():
ax1.fill_between(x, y1, y2, where=y2<=y1, facecolor='red', interpolate=True)

fig.savefig('fill_between_interpolate')
plt.close()

@image_comparison(baseline_images=['symlog'])
def test_symlog():
Expand All @@ -481,6 +502,7 @@ def test_symlog():
ax.set_ylim(-1,10000000)

fig.savefig('symlog')
plt.close()

@image_comparison(baseline_images=['pcolormesh'], tol=0.02)
def test_pcolormesh():
Expand Down Expand Up @@ -511,13 +533,15 @@ def test_pcolormesh():
ax.set_yticks([])

fig.savefig('pcolormesh')
plt.close()


@image_comparison(baseline_images=['canonical'])
def test_canonical():
fig, ax = plt.subplots()
ax.plot([1,2,3])
fig.savefig('canonical')
plt.close()


@image_comparison(baseline_images=['arc_ellipse'])
Expand Down Expand Up @@ -558,6 +582,7 @@ def test_arc_ellipse():
ax.add_patch(e2)

fig.savefig('arc_ellipse')
plt.close()

@image_comparison(baseline_images=['units_strings'])
def test_units_strings():
Expand All @@ -569,6 +594,7 @@ def test_units_strings():
ax = fig.add_subplot(111)
ax.plot(Id, pout)
fig.savefig('units_strings')
plt.close()

@image_comparison(baseline_images=['markevery'])
def test_markevery():
Expand All @@ -584,6 +610,7 @@ def test_markevery():
ax.plot(x, y, '+', markevery=(5, 20), label='mark every 5 starting at 10')
ax.legend()
fig.savefig('markevery')
plt.close()

@image_comparison(baseline_images=['markevery_line'])
def test_markevery_line():
Expand All @@ -599,6 +626,7 @@ def test_markevery_line():
ax.plot(x, y, '-+', markevery=(5, 20), label='mark every 5 starting at 10')
ax.legend()
fig.savefig('markevery_line')
plt.close()

if __name__=='__main__':
import nose
Expand Down
1 change: 1 addition & 0 deletions lib/matplotlib/tests/test_backend_pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@ def test_use14corefonts():
plt.text(0.5, 0.5, text, horizontalalignment='center', fontsize=24)
plt.axhline(0.5, linewidth=0.5)
plt.savefig('pdf_use14corefonts.pdf')
plt.close()
finally:
rcParams.update(original_rcParams)
1 change: 1 addition & 0 deletions lib/matplotlib/tests/test_backend_svg.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def test_visibility():

fd = StringIO.StringIO()
fig.savefig(fd,format='svg')
plt.close()

fd.seek(0)
buf = fd.read()
Expand Down
9 changes: 9 additions & 0 deletions lib/matplotlib/tests/test_dates.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ def test_date_empty():
ax = fig.add_subplot(1,1,1)
ax.xaxis_date()
fig.savefig('date_empty')
plt.close()

@image_comparison(baseline_images=['date_axhspan'])
def test_date_axhspan():
Expand All @@ -26,6 +27,7 @@ def test_date_axhspan():
tf+datetime.timedelta(days=5))
fig.subplots_adjust(left=0.25)
fig.savefig('date_axhspan')
plt.close()

@image_comparison(baseline_images=['date_axvspan'])
def test_date_axvspan():
Expand All @@ -39,6 +41,7 @@ def test_date_axvspan():
tf+datetime.timedelta(days=720))
fig.autofmt_xdate()
fig.savefig('date_axvspan')
plt.close()


@image_comparison(baseline_images=['date_axhline'])
Expand All @@ -53,6 +56,7 @@ def test_date_axhline():
tf+datetime.timedelta(days=5))
fig.subplots_adjust(left=0.25)
fig.savefig('date_axhline')
plt.close()

@image_comparison(baseline_images=['date_axvline'])
def test_date_axvline():
Expand All @@ -66,6 +70,7 @@ def test_date_axvline():
tf+datetime.timedelta(days=5))
fig.autofmt_xdate()
fig.savefig('date_axvline')
plt.close()

def test_too_many_date_ticks():
# Attempt to test SF 2715172, see
Expand All @@ -82,6 +87,7 @@ def test_too_many_date_ticks():
from matplotlib.dates import DayLocator, DateFormatter, HourLocator
ax.xaxis.set_major_locator(DayLocator())
assert_raises(RuntimeError, fig.savefig, 'junk.png')
plt.close()

@image_comparison(baseline_images=['RRuleLocator_bounds'])
def test_RRuleLocator():
Expand Down Expand Up @@ -112,6 +118,7 @@ def test_RRuleLocator():
fig.autofmt_xdate()

fig.savefig( 'RRuleLocator_bounds' )
plt.close()

@image_comparison(baseline_images=['DateFormatter_fractionalSeconds'])
def test_DateFormatter():
Expand Down Expand Up @@ -140,6 +147,7 @@ def test_DateFormatter():
fig.autofmt_xdate()

fig.savefig( 'DateFormatter_fractionalSeconds' )
plt.close()

#@image_comparison(baseline_images=['empty_date_bug'])
@knownfailureif(True)
Expand All @@ -158,6 +166,7 @@ def test_empty_date_with_year_formatter():
ax.xaxis.set_major_formatter(yearFmt)

fig.savefig('empty_date_bug')
plt.close()

if __name__=='__main__':
import nose
Expand Down
5 changes: 5 additions & 0 deletions lib/matplotlib/tests/test_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def test_image_interps():
ax3.set_ylabel('bicubic')

fig.savefig('image_interps')
plt.close()

@image_comparison(baseline_images=['figimage-0', 'figimage-1'], extensions=['png'], tol=1.5e-3)
def test_figimage():
Expand All @@ -48,6 +49,7 @@ def test_figimage():
fig.figimage(img[::-1,::-1], xo=100, yo=100, origin='lower')

fig.savefig('figimage-%d' % int(suppressComposite), dpi=100)
plt.close()

def test_image_python_io():
fig = plt.figure()
Expand All @@ -57,6 +59,7 @@ def test_image_python_io():
fig.savefig(buffer)
buffer.seek(0)
plt.imread(buffer)
plt.close()

# def test_image_unicode_io():
# fig = plt.figure()
Expand Down Expand Up @@ -108,6 +111,7 @@ def test_image_clip():
im = ax.imshow(d, extent=(-pi,pi,-pi/2,pi/2))

fig.savefig('image_clip')
plt.close()

@image_comparison(baseline_images=['imshow'])
def test_imshow():
Expand All @@ -122,6 +126,7 @@ def test_imshow():
ax.set_ylim(0,3)

fig.savefig('imshow')
plt.close()

if __name__=='__main__':
import nose
Expand Down
2 changes: 2 additions & 0 deletions lib/matplotlib/tests/test_legend.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def test_legend_auto1():
ax.plot(x, x-50, 'o', label='y=-1')
ax.legend(loc=0)
fig.savefig('legend_auto1')
plt.close()

@image_comparison(baseline_images=['legend_auto2'])
def test_legend_auto2():
Expand All @@ -26,4 +27,5 @@ def test_legend_auto2():
b2 = ax.bar(x, x[::-1], color='g')
ax.legend([b1[0], b2[0]], ['up', 'down'], loc=0)
fig.savefig('legend_auto2')
plt.close()

1 change: 1 addition & 0 deletions lib/matplotlib/tests/test_mathtext.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ def single_test():
fig.text(0.5, 0.5, test, horizontalalignment='center', verticalalignment='center')
fig.savefig(filename)
fig.clf()
plt.close()
matplotlib.rcParams['mathtext.fontset'] = 'cm'
return single_test

Expand Down
1 change: 1 addition & 0 deletions lib/matplotlib/tests/test_png.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ def test_pngsuite():
plt.gca().set_xlim(0, len(files))

fig.savefig('pngsuite')
plt.close()
Loading