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
This example shows how to use [bingroup](https://plot.ly/python/reference/#histogram-bingroup) attribute to have a compatible bin settings for both histograms. To define `start`, `end` and `size` value of x-axis and y-axis seperatly, set [ybins](https://plot.ly/python/reference/#histogram2dcontour-ybins) and `xbins`.
75
+
76
+
```python
77
+
import plotly.graph_objects as go
78
+
from plotly.subplots import make_subplots
79
+
80
+
fig = make_subplots(2,2)
81
+
fig.add_trace(go.Histogram2d(
82
+
x= [ 1, 2, 2, 3, 4 ],
83
+
y= [ 1, 2, 2, 3, 4 ],
84
+
coloraxis="coloraxis",
85
+
xbins= {'start':1, 'size':1}), 1,1)
86
+
fig.add_trace(go.Histogram2d(
87
+
x= [ 4, 5, 5, 5, 6 ],
88
+
y= [ 4, 5, 5, 5, 6 ],
89
+
coloraxis="coloraxis",
90
+
ybins= {'start': 3, 'size': 1}),1,2)
91
+
fig.add_trace(go.Histogram2d(
92
+
x= [ 1, 2, 2, 3, 4 ],
93
+
y= [ 1, 2, 2, 3, 4 ],
94
+
bingroup=1,
95
+
coloraxis="coloraxis",
96
+
xbins= {'start':1, 'size':1}), 2,1)
97
+
fig.add_trace(go.Histogram2d(
98
+
x= [ 4, 5, 5, 5, 6 ],
99
+
y= [ 4, 5, 5, 5, 6 ],
100
+
bingroup=1,
101
+
coloraxis="coloraxis",
102
+
ybins= {'start': 3, 'size': 1}),2,2)
103
+
fig.show()
104
+
```
73
105
74
106
### 2D Histogram Overlaid with a Scatter Chart ###
75
107
@@ -139,4 +171,3 @@ fig.show()
139
171
140
172
#### Reference
141
173
See https://plot.ly/python/reference/#histogram2d for more information and chart attribute options!
Copy file name to clipboardExpand all lines: doc/python/histograms.md
+22Lines changed: 22 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -350,6 +350,28 @@ fig1.show()
350
350
fig2.show()
351
351
```
352
352
353
+
### Share bins between histograms
354
+
In this example both histograms have a compatible bin settings using [bingroup](https://plot.ly/python/reference/#histogram-bingroup) attribute. Note that traces on the same subplot, and with the same `barmode` ("stack", "relative", "group") are forced into the same `bingroup`, however traces with `barmode = "overlay"` and on different axes (of the same axis type) can have compatible bin settings. Histogram and [histogram2d](https://plot.ly/python/2D-Histogram/) trace can share the same `bingroup`.
0 commit comments