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
+68-2
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ jupyter:
6
6
extension: .md
7
7
format_name: markdown
8
8
format_version: '1.3'
9
-
jupytext_version: 1.16.1
9
+
jupytext_version: 1.16.3
10
10
kernelspec:
11
11
display_name: Python 3 (ipykernel)
12
12
language: python
@@ -20,7 +20,7 @@ jupyter:
20
20
name: python
21
21
nbconvert_exporter: python
22
22
pygments_lexer: ipython3
23
-
version: 3.10.11
23
+
version: 3.10.14
24
24
plotly:
25
25
description: How to make SVG shapes in python. Examples of lines, circle, rectangle,
26
26
and path.
@@ -579,6 +579,72 @@ fig.update_layout(
579
579
fig.show()
580
580
```
581
581
582
+
#### Shifting Shapes on Categorical Axes
583
+
584
+
*New in 5.23*
585
+
586
+
When drawing shapes where `xref` or `yref` reference axes of type category or multicategory, you can shift `x0`, `x1`, `y0`, and `y1` away from the center of the category using `x0shift`, `x1shift`, `y0shift`, and `y1shift` by specifying a value between -1 and 1.
587
+
588
+
-1 is the center of the previous category, 0 is the center of the referenced category, and 1 is the center of the next category.
589
+
590
+
In the following example, the `x0` and `x1` values for both shapes reference category values on the x-axis.
591
+
592
+
In this example, the first shape:
593
+
- Shifts `x0` half way between the center of category "Germany" and the center of the previous category by setting `x0shift=-0.5`
594
+
- Shifts `x1`half way between the center of category "Germany" and the center of the next category by setting `x1shift=0.5`
595
+
596
+
The second shape:
597
+
- Shifts `x0` back to the center of the previous category by setting `x0shift=-1`
598
+
- Shifts `x1`forward to the center of the next category by setting `x1shift=1`
599
+
600
+
```python
601
+
import plotly.graph_objects as go
602
+
import plotly.express as px
603
+
604
+
df = px.data.gapminder().query("continent == 'Europe' and year == 1952")
0 commit comments