We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 155dd2a commit 0ed7c3dCopy full SHA for 0ed7c3d
src/tikzplotlib/_color.py
@@ -29,11 +29,15 @@
29
def _get_closest_colour_name(rgb):
30
match = None
31
mindiff = 1.0e15
32
- hex_names_dict = (
33
- webcolors.CSS3_HEX_TO_NAMES
34
- if hasattr(webcolors, "CSS3_HEX_TO_NAMES")
35
- else webcolors._definitions._CSS3_HEX_TO_NAMES
36
- )
+ if hasattr(webcolors, "names"):
+ hex_names_dict = {
+ webcolors.name_to_hex(name, spec=webcolors.CSS3): name
+ for name in webcolors.names(spec=webcolors.CSS3)
+ }
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)
0 commit comments