format a figure as a pixel-doubled (retina) PNG If `base64` is True, return base64-encoded str instead of raw bytes for binary-encoded image formats .. versionadded:: 7.29 base64 argument
(fig, base64=False, **kwargs)
| 176 | return data |
| 177 | |
| 178 | def retina_figure(fig, base64=False, **kwargs): |
| 179 | """format a figure as a pixel-doubled (retina) PNG |
| 180 | |
| 181 | If `base64` is True, return base64-encoded str instead of raw bytes |
| 182 | for binary-encoded image formats |
| 183 | |
| 184 | .. versionadded:: 7.29 |
| 185 | base64 argument |
| 186 | """ |
| 187 | pngdata = print_figure(fig, fmt="retina", base64=False, **kwargs) |
| 188 | # Make sure that retina_figure acts just like print_figure and returns |
| 189 | # None when the figure is empty. |
| 190 | if pngdata is None: |
| 191 | return |
| 192 | w, h = _pngxy(pngdata) |
| 193 | metadata = {"width": w//2, "height":h//2} |
| 194 | if base64: |
| 195 | pngdata = b2a_base64(pngdata, newline=False).decode("ascii") |
| 196 | return pngdata, metadata |
| 197 | |
| 198 | |
| 199 | # We need a little factory function here to create the closure where |
nothing calls this directly
no test coverage detected
searching dependent graphs…