Skip to content

Commit ab06784

Browse files
committed
Update supported-colors.md
1 parent 5fab7b9 commit ab06784

File tree

1 file changed

+37
-46
lines changed

1 file changed

+37
-46
lines changed

doc/python/supported-colors.md

Lines changed: 37 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ fig = go.Figure([
4646
y=[20, 14, 25, 16],
4747
name='Primary Product',
4848
# Named CSS color
49-
marker_color='indianred'
49+
marker_color='lightblue'
5050
)
5151
])
5252

@@ -95,54 +95,45 @@ supported_colors = ["aliceblue", "antiquewhite", "aqua", "aquamarine", "azure",
9595
"turquoise", "violet", "wheat", "white", "whitesmoke",
9696
"yellow", "yellowgreen"]
9797

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
98+
fig = go.Figure(layout=dict(title="Supported CSS Colors in Plotly.py"))
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
121103

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=0.1),
142110
)
143111

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+
fig.update_layout(
120+
height=((len(supported_colors) // 5) + (1 if len(supported_colors) % 5 else 0)) * 120,
121+
margin=dict(l=0, r=0, t=50, b=0),
122+
showlegend=False,
123+
plot_bgcolor='rgba(0,0,0,0)',
124+
xaxis=dict(
125+
showticklabels=False,
126+
range=[-0.5, 6]
127+
),
128+
yaxis=dict(
129+
showticklabels=False,
130+
range=[-((len(supported_colors) // 5) + 1) * 1.2, 1.5]
131+
)
132+
)
145133

146-
fig = display_colors_as_shapes(supported_colors)
147134
fig.show()
148135
```
136+
137+
```python
138+
139+
```

0 commit comments

Comments
 (0)