@@ -60,89 +60,93 @@ import plotly.graph_objects as go
60
60
import pandas as pd
61
61
62
62
supported_colors = [" aliceblue" , " antiquewhite" , " aqua" , " aquamarine" , " azure" ,
63
- " beige" , " bisque" , " black" , " blanchedalmond" , " blue" ,
64
- " blueviolet" , " brown" , " burlywood" , " cadetblue" ,
65
- " chartreuse" , " chocolate" , " coral" , " cornflowerblue" ,
66
- " cornsilk" , " crimson" , " cyan" , " darkblue" , " darkcyan" ,
67
- " darkgoldenrod" , " darkgray" , " darkgrey" , " darkgreen" ,
68
- " darkkhaki" , " darkmagenta" , " darkolivegreen" , " darkorange" ,
69
- " darkorchid" , " darkred" , " darksalmon" , " darkseagreen" ,
70
- " darkslateblue" , " darkslategray" , " darkslategrey" ,
71
- " darkturquoise" , " darkviolet" , " deeppink" , " deepskyblue" ,
72
- " dimgray" , " dimgrey" , " dodgerblue" , " firebrick" ,
73
- " floralwhite" , " forestgreen" , " fuchsia" , " gainsboro" ,
74
- " ghostwhite" , " gold" , " goldenrod" , " gray" , " grey" , " green" ,
75
- " greenyellow" , " honeydew" , " hotpink" , " indianred" , " indigo" ,
76
- " ivory" , " khaki" , " lavender" , " lavenderblush" , " lawngreen" ,
77
- " lemonchiffon" , " lightblue" , " lightcoral" , " lightcyan" ,
78
- " lightgoldenrodyellow" , " lightgray" , " lightgrey" ,
79
- " lightgreen" , " lightpink" , " lightsalmon" , " lightseagreen" ,
80
- " lightskyblue" , " lightslategray" , " lightslategrey" ,
81
- " lightsteelblue" , " lightyellow" , " lime" , " limegreen" ,
82
- " linen" , " magenta" , " maroon" , " mediumaquamarine" ,
83
- " mediumblue" , " mediumorchid" , " mediumpurple" ,
84
- " mediumseagreen" , " mediumslateblue" , " mediumspringgreen" ,
85
- " mediumturquoise" , " mediumvioletred" , " midnightblue" ,
86
- " mintcream" , " mistyrose" , " moccasin" , " navajowhite" , " navy" ,
87
- " oldlace" , " olive" , " olivedrab" , " orange" , " orangered" ,
88
- " orchid" , " palegoldenrod" , " palegreen" , " paleturquoise" ,
89
- " palevioletred" , " papayawhip" , " peachpuff" , " peru" , " pink" ,
90
- " plum" , " powderblue" , " purple" , " red" , " rosybrown" ,
91
- " royalblue" , " rebeccapurple" , " saddlebrown" , " salmon" ,
92
- " sandybrown" , " seagreen" , " seashell" , " sienna" , " silver" ,
93
- " skyblue" , " slateblue" , " slategray" , " slategrey" , " snow" ,
94
- " springgreen" , " steelblue" , " tan" , " teal" , " thistle" , " tomato" ,
95
- " turquoise" , " violet" , " wheat" , " white" , " whitesmoke" ,
96
- " yellow" , " yellowgreen" ]
97
-
98
- def display_colors_as_shapes (color_names ):
99
- fig = go.Figure(layout = dict (title = " Supported CSS Colors in Plotly.py" ))
100
-
101
- for i, color in enumerate (color_names):
102
- row, col = i // 5 , i % 5
103
- x0, y0 = col * 1.2 , - row * 1.2
104
-
105
- fig.add_shape(
106
- type = " rect" ,
107
- x0 = x0, y0 = y0,
108
- x1 = x0+ 1 , y1 = y0+ 1 ,
109
- fillcolor = color,
110
- line = dict (color = " black" , width = 1 ),
111
- )
112
-
113
- fig.add_annotation(
114
- x = x0+ 0.5 , y = y0- 0.1 ,
115
- text = color,
116
- showarrow = False ,
117
- font = dict (size = 10 )
118
- )
119
-
120
- height = ((len (color_names) // 5 ) + (1 if len (color_names) % 5 else 0 )) * 120
63
+ " beige" , " bisque" , " black" , " blanchedalmond" , " blue" ,
64
+ " blueviolet" , " brown" , " burlywood" , " cadetblue" ,
65
+ " chartreuse" , " chocolate" , " coral" , " cornflowerblue" ,
66
+ " cornsilk" , " crimson" , " cyan" , " darkblue" , " darkcyan" ,
67
+ " darkgoldenrod" , " darkgray" , " darkgrey" , " darkgreen" ,
68
+ " darkkhaki" , " darkmagenta" , " darkolivegreen" , " darkorange" ,
69
+ " darkorchid" , " darkred" , " darksalmon" , " darkseagreen" ,
70
+ " darkslateblue" , " darkslategray" , " darkslategrey" ,
71
+ " darkturquoise" , " darkviolet" , " deeppink" , " deepskyblue" ,
72
+ " dimgray" , " dimgrey" , " dodgerblue" , " firebrick" ,
73
+ " floralwhite" , " forestgreen" , " fuchsia" , " gainsboro" ,
74
+ " ghostwhite" , " gold" , " goldenrod" , " gray" , " grey" , " green" ,
75
+ " greenyellow" , " honeydew" , " hotpink" , " indianred" , " indigo" ,
76
+ " ivory" , " khaki" , " lavender" , " lavenderblush" , " lawngreen" ,
77
+ " lemonchiffon" , " lightblue" , " lightcoral" , " lightcyan" ,
78
+ " lightgoldenrodyellow" , " lightgray" , " lightgrey" ,
79
+ " lightgreen" , " lightpink" , " lightsalmon" , " lightseagreen" ,
80
+ " lightskyblue" , " lightslategray" , " lightslategrey" ,
81
+ " lightsteelblue" , " lightyellow" , " lime" , " limegreen" ,
82
+ " linen" , " magenta" , " maroon" , " mediumaquamarine" ,
83
+ " mediumblue" , " mediumorchid" , " mediumpurple" ,
84
+ " mediumseagreen" , " mediumslateblue" , " mediumspringgreen" ,
85
+ " mediumturquoise" , " mediumvioletred" , " midnightblue" ,
86
+ " mintcream" , " mistyrose" , " moccasin" , " navajowhite" , " navy" ,
87
+ " oldlace" , " olive" , " olivedrab" , " orange" , " orangered" ,
88
+ " orchid" , " palegoldenrod" , " palegreen" , " paleturquoise" ,
89
+ " palevioletred" , " papayawhip" , " peachpuff" , " peru" , " pink" ,
90
+ " plum" , " powderblue" , " purple" , " red" , " rosybrown" ,
91
+ " royalblue" , " rebeccapurple" , " saddlebrown" , " salmon" ,
92
+ " sandybrown" , " seagreen" , " seashell" , " sienna" , " silver" ,
93
+ " skyblue" , " slateblue" , " slategray" , " slategrey" , " snow" ,
94
+ " springgreen" , " steelblue" , " tan" , " teal" , " thistle" , " tomato" ,
95
+ " turquoise" , " violet" , " wheat" , " white" , " whitesmoke" ,
96
+ " yellow" , " yellowgreen" ]
97
+
98
+ fig = go.Figure(layout = dict (title = " Supported Named CSS Colors" ))
99
+
100
+ for i, color in enumerate (supported_colors):
101
+ row, col = i // 5 , i % 5
102
+ x0, y0 = col * 1.2 , - row * 1.2
121
103
122
- fig.update_layout(
123
- height = height,
124
- width = 800 ,
125
- showlegend = False ,
126
- plot_bgcolor = ' rgba(0,0,0,0)' ,
127
- margin = dict (l = 50 , r = 50 , t = 50 , b = 50 ),
128
- xaxis = dict (
129
- showgrid = False ,
130
- zeroline = False ,
131
- showticklabels = False ,
132
- range = [- 0.5 , 6 ]
133
- ),
134
- yaxis = dict (
135
- showgrid = False ,
136
- zeroline = False ,
137
- showticklabels = False ,
138
- scaleanchor = " x" ,
139
- scaleratio = 1 ,
140
- range = [- ((len (color_names) // 5 ) + 1 ) * 1.2 , 1.5 ]
141
- )
104
+ fig.add_shape(
105
+ type = " rect" ,
106
+ x0 = x0, y0 = y0,
107
+ x1 = x0+ 1 , y1 = y0+ 1 ,
108
+ fillcolor = color,
109
+ line = dict (color = " black" , width = 1 ),
142
110
)
143
111
144
- return fig
112
+ fig.add_annotation(
113
+ x = x0+ 0.5 , y = y0- 0.1 ,
114
+ text = color,
115
+ showarrow = False ,
116
+ font = dict (size = 10 )
117
+ )
118
+
119
+ height = ((len (supported_colors) // 5 ) + (1 if len (color_names) % 5 else 0 )) * 120
120
+
121
+ fig.update_layout(
122
+ height = height,
123
+ width = 800 ,
124
+ showlegend = False ,
125
+ plot_bgcolor = ' rgba(0,0,0,0)' ,
126
+ margin = dict (l = 50 , r = 50 , t = 50 , b = 50 ),
127
+ xaxis = dict (
128
+ showgrid = False ,
129
+ zeroline = False ,
130
+ showticklabels = False ,
131
+ range = [- 0.5 , 6 ]
132
+ ),
133
+ yaxis = dict (
134
+ showgrid = False ,
135
+ zeroline = False ,
136
+ showticklabels = False ,
137
+ scaleanchor = " x" ,
138
+ scaleratio = 1 ,
139
+ range = [- ((len (supported_colors) // 5 ) + 1 ) * 1.2 , 1.5 ]
140
+ )
141
+ )
145
142
146
- fig = display_colors_as_shapes(supported_colors)
147
143
fig.show()
148
144
```
145
+
146
+ ``` python
147
+
148
+ ```
149
+
150
+ ``` python
151
+
152
+ ```
0 commit comments