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

Method _repr_html_

lib/matplotlib/colors.py:2145–2175  ·  view source on GitHub ↗

Generate an HTML representation of the Colormap.

(self)

Source from the content-addressed store, hash-verified

2143 return png_bytes.getvalue()
2144
2145 def _repr_html_(self):
2146 """Generate an HTML representation of the Colormap."""
2147 png_bytes = self._repr_png_()
2148 png_base64 = base64.b64encode(png_bytes).decode('ascii')
2149 def color_block(color):
2150 hex_color = to_hex(color, keep_alpha=True)
2151 return (f'<div title="{hex_color}" '
2152 'style="display: inline-block; '
2153 'width: 1em; height: 1em; '
2154 'margin: 0; '
2155 'vertical-align: middle; '
2156 'border: 1px solid #555; '
2157 f'background-color: {hex_color};"></div>')
2158
2159 return ('<div style="vertical-align: middle;">'
2160 f'<strong>{self.name}</strong> '
2161 '</div>'
2162 '<div class="cmap"><img '
2163 f'alt="{self.name} BivarColormap" '
2164 f'title="{self.name}" '
2165 'style="border: 1px solid #555;" '
2166 f'src="data:image/png;base64,{png_base64}"></div>'
2167 '<div style="vertical-align: middle; '
2168 f'max-width: {_BIVAR_REPR_PNG_SIZE+2}px; '
2169 'display: flex; justify-content: space-between;">'
2170 '<div style="float: left;">'
2171 f'{color_block(self.get_outside())} outside'
2172 '</div>'
2173 '<div style="float: right;">'
2174 f'bad {color_block(self.get_bad())}'
2175 '</div></div>')
2176
2177 def copy(self):
2178 """Return a copy of the colormap."""

Callers

nothing calls this directly

Calls 3

_repr_png_Method · 0.95
get_outsideMethod · 0.95
get_badMethod · 0.95

Tested by

no test coverage detected