Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 12fd588

Browse files
committed
Apply CSS suggestions from @greglucas.
1 parent 9ca1893 commit 12fd588

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

lib/matplotlib/colors.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -726,31 +726,35 @@ def _repr_html_(self):
726726
"""Generate an HTML representation of the Colormap."""
727727
png_bytes = self._repr_png_()
728728
png_base64 = base64.b64encode(png_bytes).decode('ascii')
729-
def color_block(name, color):
729+
def color_block(color):
730730
hex_color = to_hex(color, keep_alpha=True)
731-
return ('<span style="margin-right: 0.8em;">' +
732-
'<span>' + name + ':</span> ' +
733-
'<div title="' + hex_color + '" ' +
731+
return ('<div title="' + hex_color + '" ' +
734732
'style="display: inline-block; ' +
735733
'width: 1em; height: 1em; ' +
736734
'margin: 0; ' +
737735
'vertical-align: middle; ' +
738736
'border: 1px solid #555; ' +
739-
'background-color: ' + hex_color + ';"></div>' +
740-
'</span>')
737+
'background-color: ' + hex_color + ';">' +
738+
'</div>')
741739

742740
return ('<div style="vertical-align: middle;">' +
743741
'<strong>' + self.name + '</strong> ' +
744742
'</div>' +
745-
'<div><img ' +
743+
'<div class="cmap"><img ' +
746744
'alt="' + self.name + ' color map" ' +
747-
'title="' + self.name + '"' +
745+
'title="' + self.name + '" ' +
748746
'style="border: 1px solid #555;" ' +
749747
'src="data:image/png;base64,' + png_base64 + '"></div>' +
750-
'<div style="vertical-align: middle;">' +
751-
color_block('under', self.get_under()) +
752-
color_block('bad', self.get_bad()) +
753-
color_block('over', self.get_over()) +
748+
'<div style="vertical-align: middle; width: 402px; ' +
749+
'display: flex; justify-content: space-between;">' +
750+
'<div style="float: left;">' +
751+
color_block(self.get_under()) + ' under' +
752+
'</div>' +
753+
'<div style="margin: 0 auto; display: inline-block;">' +
754+
'bad ' + color_block(self.get_bad()) +
755+
'</div>' +
756+
'<div style="float: right;">' +
757+
'over ' + color_block(self.get_over()) +
754758
'</div>')
755759

756760

0 commit comments

Comments
 (0)