Show More
@@ -123,6 +123,10 b" def print_figure(fig, fmt='png', bbox_inches='tight', **kwargs):" | |||
|
123 | 123 | def retina_figure(fig, **kwargs): |
|
124 | 124 | """format a figure as a pixel-doubled (retina) PNG""" |
|
125 | 125 | pngdata = print_figure(fig, fmt='retina', **kwargs) |
|
126 | # Make sure that retina_figure acts just like print_figure and returns | |
|
127 | # None when the figure is empty. | |
|
128 | if pngdata is None: | |
|
129 | return | |
|
126 | 130 | w, h = _pngxy(pngdata) |
|
127 | 131 | metadata = dict(width=w//2, height=h//2) |
|
128 | 132 | return pngdata, metadata |
@@ -66,6 +66,11 b' def test_figure_to_jpeg():' | |||
|
66 | 66 | assert jpeg.startswith(_JPEG) |
|
67 | 67 | |
|
68 | 68 | def test_retina_figure(): |
|
69 | # simple empty-figure test | |
|
70 | fig = plt.figure() | |
|
71 | nt.assert_equal(pt.retina_figure(fig), None) | |
|
72 | plt.close('all') | |
|
73 | ||
|
69 | 74 | fig = plt.figure() |
|
70 | 75 | ax = fig.add_subplot(1,1,1) |
|
71 | 76 | ax.plot([1,2,3]) |
General Comments 0
You need to be logged in to leave comments.
Login now