8000 document new methods add_shape add_annotation by emmanuelle · Pull Request #171 · plotly/plotly.py-docs · GitHub
[go: up one dir, main page]

Skip to content

document new methods add_shape add_annotation #171

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 2 commits into from
Nov 11, 2019
Merged
Show file tree
Hide file tree
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
Next Next commit
document new methods add_shape add_annotation
  • Loading branch information
emmanuelle committed Nov 5, 2019
commit fcd2a79a7957b04bb0dcf71cbf1d9a71e5790ba8
121 changes: 50 additions & 71 deletions python/shapes.md
10000
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.6
jupytext_version: 1.1.1
kernelspec:
display_name: Python 3
language: python
Expand All @@ -33,7 +33,6 @@ jupyter:
order: 32
permalink: python/shapes/
thumbnail: thumbnail/shape.jpg

v4upgrade: true
---

Expand All @@ -59,8 +58,7 @@ fig.update_xaxes(range=[0, 7])
fig.update_yaxes(range=[0, 2.5])

# Add shapes
fig.update_layout(
shapes=[
fig.add_shape(
# Line Vertical
go.layout.Shape(
type="line",
Expand All @@ -72,7 +70,8 @@ fig.update_layout(
color="RoyalBlue",
width=3
)
),
))
fig.add_shape(
# Line Horizontal
go.layout.Shape(
type="line",
Expand All @@ -85,7 +84,8 @@ fig.update_layout(
width=4,
dash="dashdot",
),
),
))
fig.add_shape(
# Line Diagonal
go.layout.Shape(
type="line",
Expand All @@ -97,11 +97,9 @@ fig.update_layout(
color="MediumPurple",
width=4,
dash="dot",
),
),
]
)

)
))
fig.update_shapes(dict(xref='x', yref='y'))
fig.show()
```

Expand All @@ -126,8 +124,7 @@ fig.update_xaxes(range=[0, 8])
fig.update_yaxes(range=[0, 2])

# Add shapes
fig.update_layout(
shapes=[
fig.add_shape(
# Line reference to the axes
go.layout.Shape(
type="line",
Expand All @@ -141,7 +138,8 @@ fig.update_layout(
color="LightSeaGreen",
width=3,
),
),
))
fig.add_shape(
# Line reference to the plot
go.layout.Shape(
type="line",
Expand All @@ -156,7 +154,6 @@ fig.update_layout(
width=3,
),
),
]
)

fig.show()
Expand All @@ -169,7 +166,7 @@ import plotly.graph_objects as go

import numpy as np

# Generate date
# Generate data
x0 = np.linspace(1, 3, 200)
y0 = x0 * np.sin(np.power(x0, 2)) + 1

Expand All @@ -187,47 +184,38 @@ fig.update_layout(
)

# Add tangent line shapes
fig.update_layout(
shapes=[
fig.add_shape(
go.layout.Shape(
type="line",
x0=1,
y0=2.30756,
x1=1.75,
y1=2.30756,
opacity=0.7,
line=dict(
color="Crimson",
width=2.5,
),
),
))
fig.add_shape(
go.layout.Shape(
type="line",
x0=2.5,
y0=3.80796,
x1=3.05,
y1=3.80796,
opacity=0.7,
line=dict(
color="Crimson",
width=2.5,
),
),
))
fig.add_shape(
go.layout.Shape(
type="line",
x0=1.90,
y0=-1.1827,
x1=2.50,
y1=-1.1827,
opacity=0.7,
line=dict(
color="Crimson",
width=2.5,
),
),
]
)

))
fig.update_shapes(dict(
xref="x",
yref="y",
opacity=0.7,
line=dict(
color="Crimson",
width=2.5,
)))
fig.show()
```

Expand All @@ -250,8 +238,7 @@ fig.update_xaxes(range=[0, 7], showgrid=False)
fig.update_yaxes(range=[0, 3.5])

# Add shapes
fig.update_layout(
shapes=[
fig.add_shape(
# unfilled Rectangle
go.layout.Shape(
type="rect",
Expand All @@ -262,7 +249,8 @@ fig.update_layout(
line=dict(
color="RoyalBlue",
),
),
))
fig.add_shape(
# filled Rectangle
go.layout.Shape(
type="rect",
Expand All @@ -275,10 +263,8 @@ fig.update_layout(
width=2,
),
fillcolor="LightSkyBlue",
),
]
)

))
fig.update_shapes(dict(xref='x', yref='y'))
fig.show()
```

Expand All @@ -303,8 +289,7 @@ fig.update_xaxes(range=[0, 4], showgrid=False)
fig.update_yaxes(range=[0, 4])

# Add shapes
fig.update_layout(
shapes=[
fig.add_shape(
# Rectangle reference to the axes
go.layout.Shape(
type="rect",
Expand All @@ -319,7 +304,8 @@ fig.update_layout(
width=3,
),
fillcolor="LightSkyBlue",
),
))
fig.add_shape(
# Rectangle reference to the plot
go.layout.Shape(
type="rect",
Expand All @@ -334,9 +320,7 @@ fig.update_layout(
width=3,
),
fillcolor="PaleTurquoise",
),
]
)
))

fig.show()
```
Expand Down Expand Up @@ -596,37 +580,32 @@ fig.update_yaxes(
)

# Add circles
fig.update_layout(
shapes=[
fig.add_shape(
go.layout.Shape(
opacity=0.3,
xref="x",
yref="y",
type="circle",
fillcolor="blue",
x0=0,
y0=0,
x1=2,
y1=2,
type="circle",
line_color="blue",
layer="below"
),
line_color="blue"
))
fig.add_shape(
go.layout.Shape(
opacity=0.3,
xref="x",
yref="y",
type="circle",
fillcolor="gray",
x0=1.5,
y0=0,
x1=3.5,
y1=2,
type="circle",
line_color="gray",
layer="below"
)
],
)

line_color="gray"
))
fig.update_shapes(dict(
opacity=0.3,
xref="x",
yref="y",
layer="below"
))
# Update figure dimensions
fig.update_layout(
margin=dict(
Expand Down
Loading
0