Skip to content

Commit fded25c

Browse files
committed
add marker updates
1 parent bd896ee commit fded25c

File tree

1 file changed

+83
-2
lines changed

1 file changed

+83
-2
lines changed

doc/python/marker-style.md

Lines changed: 83 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jupyter:
88
format_version: '1.3'
99
jupytext_version: 1.14.1
1010
kernelspec:
11-
display_name: Python 3
11+
display_name: Python 3 (ipykernel)
1212
language: python
1313
name: python3
1414
language_info:
@@ -20,7 +20,7 @@ jupyter:
2020
name: python
2121
nbconvert_exporter: python
2222
pygments_lexer: ipython3
23-
version: 3.8.8
23+
version: 3.8.0
2424
plotly:
2525
description: How to style markers in Python with Plotly.
2626
display_as: file_settings
@@ -332,6 +332,8 @@ Each basic symbol is also represented by a number. Adding 100 to that number is
332332

333333
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.
334334

335+
> The `arrow-wide` and `arrow` marker symbols are new in 5.11
336+
335337
```python
336338
import plotly.graph_objects as go
337339
from plotly.validators.scatter.marker import SymbolValidator
@@ -357,6 +359,85 @@ fig.show()
357359
```
358360

359361

362+
### Using a Custom Marker
363+
364+
To use a custom marker, set the `symbol` on the `marker`. Here we set it to `diamond`.
365+
366+
367+
```python
368+
import plotly.express as px
369+
370+
df = px.data.iris()
371+
fig = px.scatter(df, x="sepal_width", y="sepal_length", color="species")
372+
373+
fig.update_traces(marker=dict(size=8,
374+
symbol='diamond',
375+
line=dict(width=2,
376+
color='DarkSlateGrey')),
377+
selector=dict(mode='markers'))
378+
fig.show()
379+
380+
```
381+
382+
### Setting Marker Angles
383+
384+
385+
*New in 5.11*
386+
387+
Change the angle of markers by setting `angle`. Here we set the angle on the `arrow` markers to `45`.
388+
389+
```python
390+
import plotly.express as px
391+
392+
df = px.data.iris()
393+
fig = px.scatter(df, x="sepal_width", y="sepal_length", color="species")
394+
395+
fig.update_traces(marker=dict(size=12,
396+
symbol='arrow',
397+
angle=45,
398+
line=dict(width=2,
399+
color='DarkSlateGrey')),
400+
selector=dict(mode='markers'))
401+
fig.show()
402+
403+
```
404+
405+
### Setting Angle Reference
406+
407+
*New in 5.11*
408+
409+
In the previous example the angle reference is the default `up`, which
410+
means all makers start at the angle reference point of 0. Set `angleref` to `previous` and a marker will take its angle reference from the previous data point.
411+
412+
```python
413+
import pandas as pd
414+
import plotly.express as px
415+
import plotly.graph_objects as go
416+
417+
418+
df = px.data.gapminder()
419+
420+
fig = go.Figure()
421+
422+
for x in df.loc[df.continent.isin(["Europe"])].country.unique()[:5]:
423+
fil = df.loc[(df.country.str.contains(x))]
424+
fig.add_trace(
425+
go.Scatter(
426+
x=fil["year"],
427+
y=fil["pop"],
428+
mode="lines+markers",
429+
marker=dict(
430+
symbol="arrow",
431+
size=15,
432+
angleref="previous",
433+
),
434+
name=x,
435+
)
436+
)
437+
fig.show()
438+
439+
```
440+
360441
### Reference
361442

362443
See https://plotly.com/python/reference/ for more information and chart attribute options!

0 commit comments

Comments
 (0)