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/graphing-multiple-chart-types.md
+83-5Lines changed: 83 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,10 +5,10 @@ jupyter:
5
5
text_representation:
6
6
extension: .md
7
7
format_name: markdown
8
-
format_version: '1.2'
9
-
jupytext_version: 1.4.2
8
+
format_version: '1.3'
9
+
jupytext_version: 1.14.1
10
10
kernelspec:
11
-
display_name: Python 3
11
+
display_name: Python 3 (ipykernel)
12
12
language: python
13
13
name: python3
14
14
language_info:
@@ -20,7 +20,7 @@ jupyter:
20
20
name: python
21
21
nbconvert_exporter: python
22
22
pygments_lexer: ipython3
23
-
version: 3.7.7
23
+
version: 3.8.0
24
24
plotly:
25
25
description: How to design figures with multiple chart types in python.
26
26
display_as: file_settings
@@ -56,6 +56,84 @@ fig.add_bar(x=fruits, y=[2,1,3], name="Last year")
56
56
fig.show()
57
57
```
58
58
59
+
#### Grouped Bar and Scatter Chart
60
+
61
+
*New in 5.12*
62
+
63
+
In this example, we display individual data points with a grouped scatter chart and show averages using a grouped bar chart. `offsetgroup` links the bar trace for smoker with the scatter trace for smoker, and the bar trace for non-smoker with the scatter trace for non-smoker. If you deselect a trace using the legend, other traces maintain the position of the traces they are linked to.
By default, scatter points at the same location are overlayed. We can see this in the previous example, with the values for Canada for bronze and silver. Set `scattermode='group'` to plot scatter points next to one another, centered around the shared location.
You can configure the gap between groups of scatter points using `scattergap`. Here we set it to `0.75`, which brings the points closer together by allocating more space to the gap between groups. If you don't set `scattergap`, a default value of `0` is used, unless you have `bargap` set. If you have `bargap` set, the `scattergap` defaults to that value.
Copy file name to clipboardExpand all lines: doc/python/multiple-axes.md
+105-2Lines changed: 105 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ jupyter:
8
8
format_version: '1.3'
9
9
jupytext_version: 1.14.1
10
10
kernelspec:
11
-
display_name: Python 3
11
+
display_name: Python 3 (ipykernel)
12
12
language: python
13
13
name: python3
14
14
language_info:
@@ -20,7 +20,7 @@ jupyter:
20
20
name: python
21
21
nbconvert_exporter: python
22
22
pygments_lexer: ipython3
23
-
version: 3.8.8
23
+
version: 3.8.0
24
24
plotly:
25
25
description: How to make a graph with multiple axes (dual y-axis plots, plots
26
26
with secondary axes) in python.
@@ -249,5 +249,108 @@ fig.update_layout(
249
249
fig.show()
250
250
```
251
251
252
+
#### Automatically Shifting Axes
253
+
254
+
*New in 5.12*
255
+
256
+
To automatically reposition axes to avoid overlap with other axes with the same `overlaying` value, set `autoshift=True`. For `autoshift` to work on an axis, you'll also need to set `anchor="free"` on that axis.
Set a `shift` value on an axis to shift an axis by that number of pixels. A positive value shifts an axis to the right. A negative value shifts it to the left. Here, we shift `yaxis4` 100 pixels further to the left.
title_text="Shifting y-axes by a specific number of pixels",
349
+
)
350
+
351
+
fig.show()
352
+
353
+
```
354
+
252
355
#### Reference
253
356
All of the y-axis properties are found here: https://plotly.com/python/reference/YAxis/. For more information on creating subplots see the [Subplots in Python](/python/subplots/) section.
If Plotly Express does not provide a good starting point, it is also possible to use [the more generic `go.Treemap` class from `plotly.graph_objects`](/python/graph-objects/).
0 commit comments