Skip to content

Commit 26ef70b

Browse files
author
Joseph Damiba
committed
styling markers symbol example
1 parent 8a1322e commit 26ef70b

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

doc/python/marker-style.md

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -319,16 +319,20 @@ In the following figures, hover over a symbol to see its name or number. Set the
319319

320320
```python
321321
import plotly.graph_objects as go
322+
322323
fig = go.Figure()
324+
323325
fig.update_layout(title="Basic Symbols")
326+
324327
fig.update_xaxes(showticklabels=False)
325328
fig.update_yaxes(showticklabels=False)
326329

327330
for index in range(27):
328331
fig.add_trace(go.Scatter(x=[(index % 6)], y=[index // 6], name="",
329332
marker_symbol=index, marker_color='black',
330-
marker_size=10, showlegend=False,
331-
text=index, hovertemplate=f'<b>Symbol Number: {index}</b>'))
333+
marker_size=10, showlegend=False, mode="markers+text",
334+
textposition="middle right", text=f'<b>{index}</b>',
335+
hovertemplate=f'<b>Symbol Number: {index}</b>'))
332336

333337
fig.show()
334338
```
@@ -337,6 +341,7 @@ fig.show()
337341

338342
```python
339343
import plotly.graph_objects as go
344+
340345
symbols = [0, 'circle', 100, 'circle-open', 200, 'circle-dot', 300,
341346
'circle-open-dot', 1, 'square', 101, 'square-open', 201,
342347
'square-dot', 301, 'square-open-dot', 2, 'diamond', 102,
@@ -400,19 +405,21 @@ symbols = [0, 'circle', 100, 'circle-open', 200, 'circle-dot', 300,
400405
'line-nw-open']
401406

402407
fig = go.Figure()
403-
fig.update_layout(title="Custom Marker Symbols")
408+
409+
fig.update_layout(title="Custom Marker Symbols", height=800)
410+
404411
fig.update_xaxes(showticklabels=False)
405412
fig.update_yaxes(showticklabels=False)
406413

407414
for index, symbol in enumerate(symbols[::2]):
408-
fig.add_trace(go.Scatter(x=[(index % 30)], y=[index // 30],
409-
marker_symbol=symbol, marker_color='black',
410-
marker_size=10, showlegend=False,
411-
hovertext=symbols[2*index + 1], name='',
412-
hovertemplate=f'<b>{symbols[2*index + 1]}</b>'
415+
fig.add_trace(go.Scatter(x=[(index % 16)], y=[(index // 16)],
416+
marker_symbol=symbol, marker_color=index,
417+
marker_size=20, showlegend=False, mode="markers+text",
418+
name='',
419+
hovertemplate=f'<b>Symbol Name: {symbols[2*index + 1]}</b><br><b>Symbol Number: {symbols[2*index]}</b>',
420+
textfont_size=8
413421
))
414-
415-
422+
416423
fig.show()
417424
```
418425

0 commit comments

Comments
 (0)