MCPcopy Index your code
hub / github.com/plotly/plotly.py / export_color

Function export_color

plotly/matplotlylib/mplexporter/utils.py:22–37  ·  view source on GitHub ↗

Convert matplotlib color code to hex color or RGBA color

(color)

Source from the content-addressed store, hash-verified

20
21
22def export_color(color):
23 """Convert matplotlib color code to hex color or RGBA color"""
24 if color is None or colorConverter.to_rgba(color)[3] == 0:
25 return "none"
26 elif colorConverter.to_rgba(color)[3] == 1:
27 rgb = colorConverter.to_rgb(color)
28 return "#{0:02X}{1:02X}{2:02X}".format(*(int(255 * c) for c in rgb))
29 else:
30 c = colorConverter.to_rgba(color)
31 return (
32 "rgba("
33 + ", ".join(str(int(np.round(val * 255))) for val in c[:3])
34 + ", "
35 + str(c[3])
36 + ")"
37 )
38
39
40def _many_to_one(input_dict):

Callers 6

get_path_styleFunction · 0.85
get_line_styleFunction · 0.85
get_marker_styleFunction · 0.85
get_text_styleFunction · 0.85
get_grid_styleFunction · 0.85
get_axes_propertiesFunction · 0.85

Calls 2

intFunction · 0.85
formatMethod · 0.45

Tested by

no test coverage detected