Skip to content

Commit 57cbe57

Browse files
Update marker-style.md
1 parent a5291db commit 57cbe57

File tree

1 file changed

+20
-104
lines changed

1 file changed

+20
-104
lines changed

Diff for: doc/python/marker-style.md

+20-104
Original file line numberDiff line numberDiff line change
@@ -313,113 +313,29 @@ The basic symbols are: `circle`, `square`, `diamond`, `cross`, `x`, `triangle`,
313313

314314
Each basic symbol is also represented by a number. Adding 100 to that number is equivalent to appending the suffix "-open" to a symbol name. Adding 200 is equivalent to appending "-dot" to a symbol name. Adding 300 is equivalent to appending "-open-dot" or "dot-open" to a symbol name.
315315

316-
In the following figures, hover over a symbol to see its name or number. Set the `marker_symbol` attribute equal to that name or number to change the marker symbol in your figure.
317-
318-
#### Basic Symbols
319-
320-
```python
321-
import plotly.graph_objects as go
322-
323-
fig = go.Figure()
324-
325-
fig.update_layout(title="Basic Symbols")
326-
327-
fig.update_xaxes(showticklabels=False)
328-
fig.update_yaxes(showticklabels=False)
329-
330-
for index in range(27):
331-
fig.add_trace(go.Scatter(x=[(index % 6)], y=[index // 6], name="",
332-
marker_symbol=index, marker_color='black',
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>'))
336-
337-
fig.show()
338-
```
339-
340-
#### All Symbols
316+
In the following figure, hover over a symbol to see its name or number. Set the `marker_symbol` attribute equal to that name or number to change the marker symbol in your figure.
341317

342318
```python
343319
import plotly.graph_objects as go
344-
345-
symbols = [0, 'circle', 100, 'circle-open', 200, 'circle-dot', 300,
346-
'circle-open-dot', 1, 'square', 101, 'square-open', 201,
347-
'square-dot', 301, 'square-open-dot', 2, 'diamond', 102,
348-
'diamond-open', 202, 'diamond-dot', 302,
349-
'diamond-open-dot', 3, 'cross', 103, 'cross-open', 203,
350-
'cross-dot', 303, 'cross-open-dot', 4, 'x', 104, 'x-open',
351-
204, 'x-dot', 304, 'x-open-dot', 5, 'triangle-up', 105,
352-
'triangle-up-open', 205, 'triangle-up-dot', 305,
353-
'triangle-up-open-dot', 6, 'triangle-down', 106,
354-
'triangle-down-open', 206, 'triangle-down-dot', 306,
355-
'triangle-down-open-dot', 7, 'triangle-left', 107,
356-
'triangle-left-open', 207, 'triangle-left-dot', 307,
357-
'triangle-left-open-dot', 8, 'triangle-right', 108,
358-
'triangle-right-open', 208, 'triangle-right-dot', 308,
359-
'triangle-right-open-dot', 9, 'triangle-ne', 109,
360-
'triangle-ne-open', 209, 'triangle-ne-dot', 309,
361-
'triangle-ne-open-dot', 10, 'triangle-se', 110,
362-
'triangle-se-open', 210, 'triangle-se-dot', 310,
363-
'triangle-se-open-dot', 11, 'triangle-sw', 111,
364-
'triangle-sw-open', 211, 'triangle-sw-dot', 311,
365-
'triangle-sw-open-dot', 12, 'triangle-nw', 112,
366-
'triangle-nw-open', 212, 'triangle-nw-dot', 312,
367-
'triangle-nw-open-dot', 13, 'pentagon', 113,
368-
'pentagon-open', 213, 'pentagon-dot', 313,
369-
'pentagon-open-dot', 14, 'hexagon', 114, 'hexagon-open',
370-
214, 'hexagon-dot', 314, 'hexagon-open-dot', 15,
371-
'hexagon2', 115, 'hexagon2-open', 215, 'hexagon2-dot',
372-
315, 'hexagon2-open-dot', 16, 'octagon', 116,
373-
'octagon-open', 216, 'octagon-dot', 316,
374-
'octagon-open-dot', 17, 'star', 117, 'star-open', 217,
375-
'star-dot', 317, 'star-open-dot', 18, 'hexagram', 118,
376-
'hexagram-open', 218, 'hexagram-dot', 318,
377-
'hexagram-open-dot', 19, 'star-triangle-up', 119,
378-
'star-triangle-up-open', 219, 'star-triangle-up-dot', 319,
379-
'star-triangle-up-open-dot', 20, 'star-triangle-down',
380-
120, 'star-triangle-down-open', 220,
381-
'star-triangle-down-dot', 320,
382-
'star-triangle-down-open-dot', 21, 'star-square', 121,
383-
'star-square-open', 221, 'star-square-dot', 321,
384-
'star-square-open-dot', 22, 'star-diamond', 122,
385-
'star-diamond-open', 222, 'star-diamond-dot', 322,
386-
'star-diamond-open-dot', 23, 'diamond-tall', 123,
387-
'diamond-tall-open', 223, 'diamond-tall-dot', 323,
388-
'diamond-tall-open-dot', 24, 'diamond-wide', 124,
389-
'diamond-wide-open', 224, 'diamond-wide-dot', 324,
390-
'diamond-wide-open-dot', 25, 'hourglass', 125,
391-
'hourglass-open', 26, 'bowtie', 126, 'bowtie-open', 27,
392-
'circle-cross', 127, 'circle-cross-open', 28, 'circle-x',
393-
128, 'circle-x-open', 29, 'square-cross', 129,
394-
'square-cross-open', 30, 'square-x', 130, 'square-x-open',
395-
31, 'diamond-cross', 131, 'diamond-cross-open', 32,
396-
'diamond-x', 132, 'diamond-x-open', 33, 'cross-thin', 133,
397-
'cross-thin-open', 34, 'x-thin', 134, 'x-thin-open', 35,
398-
'asterisk', 135, 'asterisk-open', 36, 'hash', 136,
399-
'hash-open', 236, 'hash-dot', 336, 'hash-open-dot', 37,
400-
'y-up', 137, 'y-up-open', 38, 'y-down', 138,
401-
'y-down-open', 39, 'y-left', 139, 'y-left-open', 40,
402-
'y-right', 140, 'y-right-open', 41, 'line-ew', 141,
403-
'line-ew-open', 42, 'line-ns', 142, 'line-ns-open', 43,
404-
'line-ne', 143, 'line-ne-open', 44, 'line-nw', 144,
405-
'line-nw-open']
406-
407-
fig = go.Figure()
408-
409-
fig.update_layout(title="Custom Marker Symbols", height=800)
410-
411-
fig.update_xaxes(showticklabels=False)
412-
fig.update_yaxes(showticklabels=False)
413-
414-
for index, symbol in enumerate(symbols[::2]):
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
421-
))
422-
320+
from plotly.validators.scatter.marker import SymbolValidator
321+
322+
raw_symbols = SymbolValidator().values
323+
namestems = []
324+
namevariants = []
325+
symbols = []
326+
for i in range(0,len(raw_symbols),2):
327+
name = raw_symbols[i+1]
328+
symbols.append(raw_symbols[i])
329+
namestems.append(name.replace("-open", "").replace("-dot", ""))
330+
namevariants.append(name[len(namestems[-1]):])
331+
332+
fig = go.Figure(go.Scatter(mode="markers", x=namevariants, y=namestems, marker_symbol=symbols,
333+
marker_line_color="midnightblue", marker_color="lightskyblue",
334+
marker_line_width=2, marker_size=15,
335+
hovertemplate="name: %{y}%{x}<br>number: %{marker.symbol}<extra></extra>"))
336+
fig.update_layout(title="Mouse over symbols for name & number!",
337+
xaxis_range=[-1,4], yaxis_range=[len(set(namestems)),-1],
338+
margin=dict(b=0,r=0), xaxis_side="top", height=1200, width=400)
423339
fig.show()
424340
```
425341

0 commit comments

Comments
 (0)