Skip to content

Commit 8e5bbad

Browse files
authored
Merge pull request #2089 from plotly/filled_area_py
filled area
2 parents c7234fc + bf27e66 commit 8e5bbad

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

Diff for: doc/python/shapes.md

+21-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ jupyter:
66
extension: .md
77
format_name: markdown
88
format_version: '1.1'
9-
jupytext_version: 1.1.1
9+
jupytext_version: 1.2.1
1010
kernelspec:
1111
display_name: Python 3
1212
language: python
@@ -33,6 +33,26 @@ jupyter:
3333
thumbnail: thumbnail/shape.jpg
3434
---
3535

36+
### Filled Area Chart
37+
38+
There are two ways to draw filled shapes: scatter traces and [layout.shapes](https://plot.ly/python/reference/#layout-shapes-items-shape-type) which is mostly useful for the 2d subplots, and defines the shape type to be drawn, and can be rectangle, circle, line, or path (a custom SVG path). You also can use [scatterpolar](https://plot.ly/python/polar-chart/#categorical-polar-chart), scattergeo, [scattermapbox](https://plot.ly/python/filled-area-on-mapbox/#filled-scattermapbox-trace) to draw filled shapes on any kind of subplots. To set an area to be filled with a solid color, you need to define [Scatter.fill="toself"](https://plot.ly/python/reference/#scatter-fill) that connects the endpoints of the trace into a closed shape. If `mode=line` (default value), then you need to repeat the initial point of a shape at the of the sequence to have a closed shape.
39+
40+
```python
41+
import plotly.graph_objects as go
42+
43+
fig = go.Figure(go.Scatter(x=[0,1,2,0], y=[0,2,0,0], fill="toself"))
44+
fig.show()
45+
```
46+
47+
You can have more shapes either by adding [more traces](https://plot.ly/python/filled-area-plots/) or interrupting the series with `None`.
48+
49+
```python
50+
import plotly.graph_objects as go
51+
52+
fig = go.Figure(go.Scatter(x=[0,1,2,0,None,3,3,5,5,3], y=[0,2,0,0,None,0.5,1.5,1.5,0.5,0.5], fill="toself"))
53+
fig.show()
54+
```
55+
3656
#### Vertical and Horizontal Lines Positioned Relative to the Axes
3757

3858
```python

0 commit comments

Comments
 (0)