Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/tikzplotlib/_color.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,16 @@
def _get_closest_colour_name(rgb):
match = None
mindiff = 1.0e15
for h, name in webcolors.CSS3_HEX_TO_NAMES.items():
if hasattr(webcolors, "names"):
hex_names_dict = {
webcolors.name_to_hex(name, spec=webcolors.CSS3): name
for name in webcolors.names(spec=webcolors.CSS3)
}
elif hasattr(webcolors, "CSS3_HEX_TO_NAMES"):
hex_names_dict = webcolors.CSS3_HEX_TO_NAMES
else:
hex_names_dict = webcolors._definitions._CSS3_HEX_TO_NAMES
for h, name in hex_names_dict.items():
r = int(h[1:3], 16)
g = int(h[3:5], 16)
b = int(h[5:7], 16)
Expand Down