@@ -34,11 +34,16 @@ jupyter:
34
34
35
35
### Horizontal and Vertical Lines and Boxes (Autoshapes) in Plotly.py
36
36
37
+ * introduced in plotly 4.12*
38
+
37
39
Horizontal and vertical lines and rectangles (autoshapes) that span an entire
38
40
plot can be added via the ` add_hline ` , ` add_vline ` , ` add_hrect ` , and ` add_vrect `
39
- methods of ` plotly.graph_objects.Figure ` . These shapes are fixed to the
40
- endpoints of one axis, regardless of the range of the plot, and fixed to data
41
- coordinates on the other axis. For example
41
+ methods of ` plotly.graph_objects.Figure ` . Shapes added with these methods are
42
+ added as [ layout shapes] ( /python/shapes ) (as shown when doing ` print(fig) ` , for
43
+ example). These shapes are fixed to the endpoints of one axis, regardless of the
44
+ range of the plot, and fixed to data coordinates on the other axis. The
45
+ following shows some possibilities, try panning and zooming the resulting figure
46
+ to see how the shapes stick to some axes:
42
47
43
48
44
49
``` python
@@ -59,7 +64,7 @@ fig.add_vrect(x0=5.5, x1=6.5, line_color="purple")
59
64
# Add a horizontal rectangle that spans the entire x axis
60
65
# intersecting the y axis at 2.5 and 4
61
66
fig.add_hrect(y0 = 2.5 , y1 = 4 , line_color = " orange" )
62
- # (try dragging the plot around )
67
+ # (try panning and zooming the plot)
63
68
fig.show()
64
69
```
65
70
@@ -88,8 +93,8 @@ example.
88
93
89
94
#### Adding Text Annotations to Autoshapes
90
95
91
- Text can be added to an autoshape using the ` annotation ` keyword. Using the
92
- above example:
96
+ Text [ annotations ] ( /python/text-and-annotations ) can be added to an autoshape
97
+ using the ` annotation ` keyword. Using the above example:
93
98
``` python
94
99
import plotly.express as px
95
100
import plotly.graph_objects as go
0 commit comments