-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Add marker symbols example #2188
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
42746dc
Merge branch 'doc-prod'
nicolaskruchten ff4df85
added some items in release process notes
emmanuelle 2b06173
mention getting-started
emmanuelle 7483fbb
changed order of imports for better error messages (#2132)
emmanuelle d14d842
Merge branch 'doc-prod'
nicolaskruchten d7fc1bc
tweaks to make flake8 happy
nicolaskruchten e9fa00d
g -> trace_data
nicolaskruchten ca87353
k -> attr_name
nicolaskruchten e7ced12
v -> attr_value
nicolaskruchten 94303bc
v_label -> attr_label
nicolaskruchten 95f78c2
result -> trace_patch
nicolaskruchten 4bf740b
Merge pull request #2135 from plotly/cleanup
nicolaskruchten 51fa1ee
Merge pull request #2128 from plotly/contributing
nicolaskruchten f7dc2be
Sunburst improvements (#2133)
emmanuelle 9fb88c1
Merge doc prod2 (#2179)
emmanuelle 00c3238
prevent creation of new px.default properties at run time
0eda9f8
prevent creation of new px.default properties at run time
633c2da
run black
bae0483
add test for permissive defaults
58aeb32
formatting
756f09b
formatting
bdda851
make sure new test is picked up by pytest
f4a005d
Merge pull request #2183 from plotly/px-permissive-defaults
ca903a4
add marker symbol example
061afb5
fix typo
fe369aa
be more explicit about basic/advanced shapes
1b32242
Merge branch 'master' into add-marker-symbols
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -5,8 +5,8 @@ jupyter: | |||||
text_representation: | ||||||
extension: .md | ||||||
format_name: markdown | ||||||
format_version: "1.1" | ||||||
jupytext_version: 1.1.7 | ||||||
format_version: '1.2' | ||||||
jupytext_version: 1.3.2 | ||||||
kernelspec: | ||||||
display_name: Python 3 | ||||||
language: python | ||||||
|
@@ -20,7 +20,7 @@ jupyter: | |||||
name: python | ||||||
nbconvert_exporter: python | ||||||
pygments_lexer: ipython3 | ||||||
version: 3.6.5 | ||||||
version: 3.7.0 | ||||||
plotly: | ||||||
description: How to style markers in Python with Plotly. | ||||||
display_as: file_settings | ||||||
|
@@ -305,6 +305,115 @@ fig.show() | |||||
|
||||||
``` | ||||||
|
||||||
### Custom Marker Symbols | ||||||
|
||||||
The `marker_symbol` attribute allows you to choose from a wide array of symbols to represent markers in your figures. | ||||||
|
||||||
The basic symbols are: `circle`, `square`, `diamond`, `cross`, `x`, `triangle`, `pentagon`, `hexagram`, `star`, `diamond`, `hourglass`, `bowtie`, `asterisk`, `hash`, `y`, and `line`. | ||||||
|
||||||
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. | ||||||
|
||||||
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. | ||||||
|
||||||
#### Basic Symbols | ||||||
|
||||||
```python | ||||||
import plotly.graph_objects as go | ||||||
fig = go.Figure() | ||||||
fig.update_layout(title="Basic Symbols") | ||||||
fig.update_xaxes(showticklabels=False) | ||||||
fig.update_yaxes(showticklabels=False) | ||||||
|
||||||
for index in range(27): | ||||||
fig.add_trace(go.Scatter(x=[(index % 30)], y=[index // 30], | ||||||
marker_symbol=index, marker_color='black', | ||||||
marker_size=10, showlegend=False, hovertext=index)) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you're not tired of me nitpicking you could use a hovertemplate here to show just the index, not the coordinates. |
||||||
|
||||||
fig.show() | ||||||
``` | ||||||
|
||||||
#### Custom Symbols | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
```python | ||||||
import plotly.graph_objects as go | ||||||
symbols = [0, 'circle', 100, 'circle-open', 200, 'circle-dot', 300, | ||||||
'circle-open-dot', 1, 'square', 101, 'square-open', 201, | ||||||
'square-dot', 301, 'square-open-dot', 2, 'diamond', 102, | ||||||
'diamond-open', 202, 'diamond-dot', 302, | ||||||
'diamond-open-dot', 3, 'cross', 103, 'cross-open', 203, | ||||||
'cross-dot', 303, 'cross-open-dot', 4, 'x', 104, 'x-open', | ||||||
204, 'x-dot', 304, 'x-open-dot', 5, 'triangle-up', 105, | ||||||
'triangle-up-open', 205, 'triangle-up-dot', 305, | ||||||
'triangle-up-open-dot', 6, 'triangle-down', 106, | ||||||
'triangle-down-open', 206, 'triangle-down-dot', 306, | ||||||
'triangle-down-open-dot', 7, 'triangle-left', 107, | ||||||
'triangle-left-open', 207, 'triangle-left-dot', 307, | ||||||
'triangle-left-open-dot', 8, 'triangle-right', 108, | ||||||
'triangle-right-open', 208, 'triangle-right-dot', 308, | ||||||
'triangle-right-open-dot', 9, 'triangle-ne', 109, | ||||||
'triangle-ne-open', 209, 'triangle-ne-dot', 309, | ||||||
'triangle-ne-open-dot', 10, 'triangle-se', 110, | ||||||
'triangle-se-open', 210, 'triangle-se-dot', 310, | ||||||
'triangle-se-open-dot', 11, 'triangle-sw', 111, | ||||||
'triangle-sw-open', 211, 'triangle-sw-dot', 311, | ||||||
'triangle-sw-open-dot', 12, 'triangle-nw', 112, | ||||||
'triangle-nw-open', 212, 'triangle-nw-dot', 312, | ||||||
'triangle-nw-open-dot', 13, 'pentagon', 113, | ||||||
'pentagon-open', 213, 'pentagon-dot', 313, | ||||||
'pentagon-open-dot', 14, 'hexagon', 114, 'hexagon-open', | ||||||
214, 'hexagon-dot', 314, 'hexagon-open-dot', 15, | ||||||
'hexagon2', 115, 'hexagon2-open', 215, 'hexagon2-dot', | ||||||
315, 'hexagon2-open-dot', 16, 'octagon', 116, | ||||||
'octagon-open', 216, 'octagon-dot', 316, | ||||||
'octagon-open-dot', 17, 'star', 117, 'star-open', 217, | ||||||
'star-dot', 317, 'star-open-dot', 18, 'hexagram', 118, | ||||||
'hexagram-open', 218, 'hexagram-dot', 318, | ||||||
'hexagram-open-dot', 19, 'star-triangle-up', 119, | ||||||
'star-triangle-up-open', 219, 'star-triangle-up-dot', 319, | ||||||
'star-triangle-up-open-dot', 20, 'star-triangle-down', | ||||||
120, 'star-triangle-down-open', 220, | ||||||
'star-triangle-down-dot', 320, | ||||||
'star-triangle-down-open-dot', 21, 'star-square', 121, | ||||||
'star-square-open', 221, 'star-square-dot', 321, | ||||||
'star-square-open-dot', 22, 'star-diamond', 122, | ||||||
'star-diamond-open', 222, 'star-diamond-dot', 322, | ||||||
'star-diamond-open-dot', 23, 'diamond-tall', 123, | ||||||
'diamond-tall-open', 223, 'diamond-tall-dot', 323, | ||||||
'diamond-tall-open-dot', 24, 'diamond-wide', 124, | ||||||
'diamond-wide-open', 224, 'diamond-wide-dot', 324, | ||||||
'diamond-wide-open-dot', 25, 'hourglass', 125, | ||||||
'hourglass-open', 26, 'bowtie', 126, 'bowtie-open', 27, | ||||||
'circle-cross', 127, 'circle-cross-open', 28, 'circle-x', | ||||||
128, 'circle-x-open', 29, 'square-cross', 129, | ||||||
'square-cross-open', 30, 'square-x', 130, 'square-x-open', | ||||||
31, 'diamond-cross', 131, 'diamond-cross-open', 32, | ||||||
'diamond-x', 132, 'diamond-x-open', 33, 'cross-thin', 133, | ||||||
'cross-thin-open', 34, 'x-thin', 134, 'x-thin-open', 35, | ||||||
'asterisk', 135, 'asterisk-open', 36, 'hash', 136, | ||||||
'hash-open', 236, 'hash-dot', 336, 'hash-open-dot', 37, | ||||||
'y-up', 137, 'y-up-open', 38, 'y-down', 138, | ||||||
'y-down-open', 39, 'y-left', 139, 'y-left-open', 40, | ||||||
'y-right', 140, 'y-right-open', 41, 'line-ew', 141, | ||||||
'line-ew-open', 42, 'line-ns', 142, 'line-ns-open', 43, | ||||||
'line-ne', 143, 'line-ne-open', 44, 'line-nw', 144, | ||||||
'line-nw-open'] | ||||||
|
||||||
fig = go.Figure() | ||||||
fig.update_layout(title="Custom Marker Symbols") | ||||||
fig.update_xaxes(showticklabels=False) | ||||||
fig.update_yaxes(showticklabels=False) | ||||||
|
||||||
for index, symbol in enumerate(symbols[::2]): | ||||||
fig.add_trace(go.Scatter(x=[(index % 30)], y=[index // 30], | ||||||
marker_symbol=symbol, marker_color='black', | ||||||
marker_size=10, showlegend=False, hovertext=symbols[2*index + 1], | ||||||
name='')) | ||||||
|
||||||
|
||||||
fig.show() | ||||||
``` | ||||||
|
||||||
|
||||||
### Reference | ||||||
|
||||||
See https://plot.ly/python/reference/ for more information and chart attribute options! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would use 6 here instead of 30 so that the symbols appear on several lines.