Skip to content

Commit fcab197

Browse files
authored
Merge pull request #2226 from SylwiaOliwia2/patch-1
Update subplots.md
2 parents c86e0c9 + ebf4ba5 commit fcab197

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

Diff for: doc/python/subplots.md

+22
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,28 @@ fig.update_layout(height=600, width=600,
296296
fig.show()
297297
```
298298

299+
### Subplots with Shared Colorscale
300+
301+
To share colorscale information in multiple subplots, you can use [coloraxis](https://plot.ly/javascript/reference/#scatter-marker-line-coloraxis).
302+
303+
```python
304+
from plotly.subplots import make_subplots
305+
import plotly.graph_objects as go
306+
307+
fig = make_subplots(rows=1, cols=2, shared_yaxes=True)
308+
309+
fig.add_trace(go.Bar(x=[1, 2, 3], y=[4, 5, 6],
310+
marker=dict(color=[4, 5, 6], coloraxis="coloraxis")),
311+
1, 1)
312+
313+
fig.add_trace(go.Bar(x=[1, 2, 3], y=[2, 3, 5],
314+
marker=dict(color=[2, 3, 5], coloraxis="coloraxis")),
315+
1, 2)
316+
317+
fig.update_layout(coloraxis=dict(colorscale='Bluered_r'), showlegend=False)
318+
fig.show()
319+
```
320+
299321
#### Custom Sized Subplot with Subplot Titles
300322
The `specs` argument to `make_subplots` is used to configure per-subplot options. `specs` must be a 2-dimension list with dimensions that match those provided as the `rows` and `cols` arguments. The elements of `specs` may either be `None`, indicating no subplot should be initialized starting with this grid cell, or a dictionary containing subplot options. The `colspan` subplot option specifies the number of grid columns that the subplot starting in the given cell should occupy. If unspecified, `colspan` defaults to 1.
301323

0 commit comments

Comments
 (0)