Generate a PNG representation of the Colormap.
(self)
| 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.""" |