Skip to content

Commit ae1604a

Browse files
committed
update styles and formatting
1 parent 9670c4a commit ae1604a

File tree

1 file changed

+25
-13
lines changed

1 file changed

+25
-13
lines changed

doc/python/shapes.md

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ jupyter:
66
extension: .md
77
format_name: markdown
88
format_version: '1.3'
9-
jupytext_version: 1.14.1
9+
jupytext_version: 1.14.5
1010
kernelspec:
11-
display_name: Python 3
11+
display_name: Python 3 (ipykernel)
1212
language: python
1313
name: python3
1414
language_info:
@@ -20,7 +20,7 @@ jupyter:
2020
name: python
2121
nbconvert_exporter: python
2222
pygments_lexer: ipython3
23-
version: 3.8.8
23+
version: 3.10.9
2424
plotly:
2525
description: How to make SVG shapes in python. Examples of lines, circle, rectangle,
2626
and path.
@@ -676,15 +676,23 @@ import plotly.graph_objects as go
676676

677677
fig = go.Figure()
678678

679-
fig.add_shape(type="rect", x0=1, y0=1, x1=2, y1=3, label=dict(text="Text in rectangle"))
679+
fig.add_shape(
680+
type="rect",
681+
fillcolor='turquoise',
682+
x0=1,
683+
y0=1,
684+
x1=2,
685+
y1=3,
686+
label=dict(text="Text in rectangle")
687+
)
680688
fig.add_shape(
681689
type="line",
682690
x0=3,
683691
y0=0.5,
684692
x1=5,
685693
y1=0.8,
686694
line_width=3,
687-
label=dict(text="Text above line"),
695+
label=dict(text="Text above line")
688696
)
689697

690698
fig.show()
@@ -694,7 +702,7 @@ fig.show()
694702
#### Styling Text Labels
695703

696704
Use the `font` property to configure the `color`, `size`, and `family` of the label font.
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.
705+
In this example, we change the label color of the first rectangle to "DarkOrange", 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.
698706

699707
```python
700708
import plotly.graph_objects as go
@@ -703,11 +711,12 @@ fig = go.Figure()
703711

704712
fig.add_shape(
705713
type="rect",
714+
fillcolor='MediumSlateBlue',
706715
x0=1,
707716
y0=1,
708717
x1=2,
709718
y1=3,
710-
label=dict(text="Text in rectangle", font=dict(color="red")),
719+
label=dict(text="Text in rectangle", font=dict(color="DarkOrange")),
711720
)
712721
fig.add_shape(
713722
type="line",
@@ -720,6 +729,7 @@ fig.add_shape(
720729
)
721730
fig.add_shape(
722731
type="rect",
732+
fillcolor='Lavender',
723733
x0=2.5,
724734
y0=2.5,
725735
x1=5,
@@ -745,6 +755,7 @@ fig = go.Figure()
745755

746756
fig.add_shape(
747757
type="rect",
758+
fillcolor='Lavender',
748759
x0=0,
749760
y0=0,
750761
x1=1.5,
@@ -754,6 +765,7 @@ fig.add_shape(
754765

755766
fig.add_shape(
756767
type="rect",
768+
fillcolor='Lavender',
757769
x0=3,
758770
y0=0,
759771
x1=4.5,
@@ -764,6 +776,7 @@ fig.add_shape(
764776

765777
fig.add_shape(
766778
type="line",
779+
line_color="MediumSlateBlue",
767780
x0=3,
768781
y0=2,
769782
x1=5,
@@ -775,6 +788,7 @@ fig.add_shape(
775788

776789
fig.add_shape(
777790
type="line",
791+
line_color="MediumSlateBlue",
778792
x0=0,
779793
y0=2,
780794
x1=2,
@@ -798,6 +812,7 @@ fig = go.Figure()
798812

799813
fig.add_shape(
800814
type="rect",
815+
fillcolor='LightGreen',
801816
x0=0,
802817
y0=0,
803818
x1=2,
@@ -807,6 +822,7 @@ fig.add_shape(
807822

808823
fig.add_shape(
809824
type="rect",
825+
fillcolor='Gold',
810826
x0=3,
811827
y0=0,
812828
x1=5,
@@ -827,9 +843,9 @@ import plotly.graph_objects as go
827843

828844
fig = go.Figure()
829845

830-
831846
fig.add_shape(
832847
type="line",
848+
line_color="RoyalBlue",
833849
x0=3,
834850
y0=0,
835851
x1=5,
@@ -838,9 +854,9 @@ fig.add_shape(
838854
label=dict(text="Label padding of 30", padding=30),
839855
)
840856

841-
842857
fig.add_shape(
843858
type="line",
859+
line_color="RoyalBlue",
844860
x0=0,
845861
y0=0,
846862
x1=2,
@@ -849,9 +865,7 @@ fig.add_shape(
849865
label=dict(text="No label padding"),
850866
)
851867

852-
853868
fig.show()
854-
855869
```
856870

857871
#### Setting Label Anchors
@@ -880,7 +894,6 @@ fig.add_shape(
880894
opacity=0.25,
881895
)
882896

883-
884897
fig.add_shape(
885898
type="line",
886899
x0=min(df.index),
@@ -898,7 +911,6 @@ fig.add_shape(
898911
)
899912

900913
fig.show()
901-
902914
```
903915

904916
### Reference

0 commit comments

Comments
 (0)