Last active
January 6, 2025 14:04
-
-
Save wmayner/9b099a0e4a5f8e94f0c6ab2f570187a5 to your computer and use it in GitHub Desktop.
Display a color swatch from hex color strings with IPython in a Jupyter Notebook
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from IPython.display import Markdown, display | |
colors = ['#018700', '#00acc6', '#e6a500'] | |
display(Markdown('<br>'.join( | |
f'<span style="font-family: monospace">{color} <span style="color: {color}">████████</span></span>' | |
for color in colors | |
))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note that Google Collaboratory sanitizes HTML in Markdown. I'd recommend using Html instead of Markdown, which I think makes the intent more clear anyway.