Skip to content

filled area #2089

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

Merged
merged 3 commits into from
Jan 21, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion doc/python/shapes.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jupyter:
extension: .md
format_name: markdown
format_version: '1.1'
jupytext_version: 1.1.1
jupytext_version: 1.2.1
kernelspec:
display_name: Python 3
language: python
Expand Down Expand Up @@ -682,5 +682,25 @@ fig.update_layout(
fig.show()
```

### Filled Area Chart
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would move this to the very top, with a little intro saying "there are two ways to draw filled shapes: scatter traces and layout.shapes" with a note that layout.shapes is mostly useful for cartesian 2d subplots, but you can use e.g. scatterpolar and scattergeo and scattermapbox to draw filled shapes on any kind of subplots.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can add a link to the scatterpolar page where we have filled shapes, and to the "filled shapes on mapbox" page that you wrote last year?


So far we saw [layout.shapes](https://plot.ly/python/reference/#layout-shapes-items-shape-type) defines the shape type to be drawn, which can be rectangle, circle, line, or path (a custom SVG path). You also can set an area to be filled with a solid color by defining [Scatter.fill="toself"](https://plot.ly/python/reference/#scatter-fill) that connects the endpoints of the trace into a closed shape.

```python
import plotly.graph_objects as go

fig = go.Figure(go.Scatter(x=[0,1,2], y=[0,2,0], fill="toself"))
fig.show()
```

You can have more shapes either by adding [more traces](https://plot.ly/python/filled-area-plots/) or interupting the series with `None`.

```python
import plotly.graph_objects as go

fig = go.Figure(go.Scatter(x=[0,1,2,None,3,3,5,5], y=[0,2,0,None,0.5,1.5,1.5,0.5], fill="toself"))
fig.show()
```

### Reference
See https://plot.ly/python/reference/#layout-shapes for more information and chart attribute options!