We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 6b3e063 + fedd580 commit e7438b5Copy full SHA for e7438b5
1 file changed
src/tikzplotlib/_color.py
@@ -29,7 +29,16 @@
29
def _get_closest_colour_name(rgb):
30
match = None
31
mindiff = 1.0e15
32
- for h, name in webcolors.CSS3_HEX_TO_NAMES.items():
+ 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():
42
r = int(h[1:3], 16)
43
g = int(h[3:5], 16)
44
b = int(h[5:7], 16)
0 commit comments