You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/python/shapes.md
+60-6
Original file line number
Diff line number
Diff line change
@@ -691,7 +691,7 @@ fig.show()
691
691
692
692
```
693
693
694
-
### Styling Text Labels
694
+
####Styling Text Labels
695
695
696
696
Use the `font` property to configure the `color`, `size`, and `family` of the label font.
697
697
In this example, we change the label color of the first rectangle to "red", set the size of the text above the line to 20, and change the font family and set the font size on the second rectangle.
@@ -733,7 +733,7 @@ fig.show()
733
733
734
734
```
735
735
736
-
### Setting Label Position
736
+
####Setting Label Position
737
737
738
738
Set a label's position relative to the shape by setting `textposition`. The default position for lines is `middle`. The default position for other shapes is `middle center`.
739
739
@@ -787,7 +787,7 @@ fig.show()
787
787
788
788
```
789
789
790
-
### Setting Label Angle
790
+
####Setting Label Angle
791
791
792
792
Use `textangle` to rotate a label by setting a value between -180 and 180. The default angle for a label on a line is the angle of the line. The default angle for a label on other shapes is 0. In this example, in the first shape, the label is at 45 degrees, and in the second, the label is at -45 degrees.
793
793
@@ -809,16 +809,16 @@ fig.add_shape(
809
809
type="rect",
810
810
x0=3,
811
811
y0=0,
812
-
x1=4.5,
813
-
y1=1.5,
812
+
x1=5,
813
+
y1=2,
814
814
label=dict(text="Text at -45", textangle=-45),
815
815
)
816
816
817
817
fig.show()
818
818
819
819
```
820
820
821
-
### Setting Label Padding
821
+
####Setting Label Padding
822
822
823
823
`padding` adds padding between the label and shape. This example shows one line with padding of 30px and another with the default padding, which is 3px.
824
824
@@ -849,9 +849,63 @@ fig.add_shape(
849
849
label=dict(text="No label padding"),
850
850
)
851
851
852
+
852
853
fig.show()
853
854
854
855
```
855
856
857
+
#### Setting Label Anchors
858
+
859
+
`xanchor` sets a label's horizontal positional anchor and `yanchor` sets its vertical position anchor.
860
+
Use `xanchor` to bind the `textposition` to the "left", "center" or "right" of the label text and `yanchor` to bind `textposition` to the "top", "middle" or "bottom" of the label text.
861
+
862
+
In this example, `yanchor`is set to "top", instead of the default of "bottom" for lines, meaning the text displays below the line.
0 commit comments