Show More
@@ -123,6 +123,10 b" def print_figure(fig, fmt='png', bbox_inches='tight', **kwargs):" | |||||
123 | def retina_figure(fig, **kwargs): |
|
123 | def retina_figure(fig, **kwargs): | |
124 | """format a figure as a pixel-doubled (retina) PNG""" |
|
124 | """format a figure as a pixel-doubled (retina) PNG""" | |
125 | pngdata = print_figure(fig, fmt='retina', **kwargs) |
|
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 | w, h = _pngxy(pngdata) |
|
130 | w, h = _pngxy(pngdata) | |
127 | metadata = dict(width=w//2, height=h//2) |
|
131 | metadata = dict(width=w//2, height=h//2) | |
128 | return pngdata, metadata |
|
132 | return pngdata, metadata |
@@ -66,6 +66,11 b' def test_figure_to_jpeg():' | |||||
66 | assert jpeg.startswith(_JPEG) |
|
66 | assert jpeg.startswith(_JPEG) | |
67 |
|
67 | |||
68 | def test_retina_figure(): |
|
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 | fig = plt.figure() |
|
74 | fig = plt.figure() | |
70 | ax = fig.add_subplot(1,1,1) |
|
75 | ax = fig.add_subplot(1,1,1) | |
71 | ax.plot([1,2,3]) |
|
76 | ax.plot([1,2,3]) |
General Comments 0
You need to be logged in to leave comments.
Login now