MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / _repr_png_

Method _repr_png_

lib/matplotlib/colors.py:1022–1036  ·  view source on GitHub ↗

Generate a PNG representation of the Colormap.

(self)

Source from the content-addressed store, hash-verified

1020 raise NotImplementedError()
1021
1022 def _repr_png_(self):
1023 """Generate a PNG representation of the Colormap."""
1024 X = np.tile(np.linspace(0, 1, _REPR_PNG_SIZE[0]),
1025 (_REPR_PNG_SIZE[1], 1))
1026 pixels = self(X, bytes=True)
1027 png_bytes = io.BytesIO()
1028 title = self.name + ' colormap'
1029 author = f'Matplotlib v{mpl.__version__}, https://matplotlib.org'
1030 pnginfo = PngInfo()
1031 pnginfo.add_text('Title', title)
1032 pnginfo.add_text('Description', title)
1033 pnginfo.add_text('Author', author)
1034 pnginfo.add_text('Software', author)
1035 Image.fromarray(pixels).save(png_bytes, format='png', pnginfo=pnginfo)
1036 return png_bytes.getvalue()
1037
1038 def _repr_html_(self):
1039 """Generate an HTML representation of the Colormap."""

Callers 7

_repr_html_Method · 0.95
test_bivariate_repr_pngFunction · 0.45
test_bivariate_repr_htmlFunction · 0.45
test_repr_pngFunction · 0.45
test_repr_htmlFunction · 0.45

Calls 1

saveMethod · 0.80

Tested by 6

test_bivariate_repr_pngFunction · 0.36
test_bivariate_repr_htmlFunction · 0.36
test_repr_pngFunction · 0.36
test_repr_htmlFunction · 0.36