Skip to content

Commit e7438b5

Browse files
committed
Merge branch 'pr-619'
2 parents 6b3e063 + fedd580 commit e7438b5

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

src/tikzplotlib/_color.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,16 @@
2929
def _get_closest_colour_name(rgb):
3030
match = None
3131
mindiff = 1.0e15
32-
for h, name in webcolors.CSS3_HEX_TO_NAMES.items():
32+
if hasattr(webcolors, "names"):
33+
hex_names_dict = {
34+
webcolors.name_to_hex(name, spec=webcolors.CSS3): name
35+
for name in webcolors.names(spec=webcolors.CSS3)
36+
}
37+
elif hasattr(webcolors, "CSS3_HEX_TO_NAMES"):
38+
hex_names_dict = webcolors.CSS3_HEX_TO_NAMES
39+
else:
40+
hex_names_dict = webcolors._definitions._CSS3_HEX_TO_NAMES
41+
for h, name in hex_names_dict.items():
3342
r = int(h[1:3], 16)
3443
g = int(h[3:5], 16)
3544
b = int(h[5:7], 16)

0 commit comments

Comments
 (0)