@@ -34,11 +34,16 @@ jupyter:
3434
3535### Horizontal and Vertical Lines and Boxes (Autoshapes) in Plotly.py
3636
37+ * introduced in plotly 4.12*
38+
3739Horizontal and vertical lines and rectangles (autoshapes) that span an entire
3840plot 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:
4247
4348
4449``` python
@@ -59,7 +64,7 @@ fig.add_vrect(x0=5.5, x1=6.5, line_color="purple")
5964# Add a horizontal rectangle that spans the entire x axis
6065# intersecting the y axis at 2.5 and 4
6166fig.add_hrect(y0 = 2.5 , y1 = 4 , line_color = " orange" )
62- # (try dragging the plot around )
67+ # (try panning and zooming the plot)
6368fig.show()
6469```
6570
@@ -88,8 +93,8 @@ example.
8893
8994#### Adding Text Annotations to Autoshapes
9095
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:
9398``` python
9499import plotly.express as px
95100import plotly.graph_objects as go
0 commit comments