MCPcopy Index your code
hub / github.com/ipython/ipython / retina_figure

Function retina_figure

IPython/core/pylabtools.py:178–196  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

176 return data
177
178def 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

Callers

nothing calls this directly

Calls 2

_pngxyFunction · 0.90
print_figureFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…