From eca01a6e72fed9cc309029ba4c2bc5e112a59000 Mon Sep 17 00:00:00 2001 From: Sylwia Mielnicka Date: Tue, 25 Feb 2020 10:29:07 +0100 Subject: [PATCH 1/2] Update subplots.md Add information about coloraxis in subplots. Issue #1965. --- doc/python/subplots.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/doc/python/subplots.md b/doc/python/subplots.md index d1f411797d..d0e268d173 100644 --- a/doc/python/subplots.md +++ b/doc/python/subplots.md @@ -296,6 +296,24 @@ fig.update_layout(height=600, width=600, fig.show() ``` +### Subplots with Shared Colorscale + +To share colorscale information in multiple subplots, you can use [coloraxis](https://plot.ly/javascript/reference/#scatter-marker-line-coloraxis). + +```python +from plotly.subplots import make_subplots +import plotly.graph_objects as go +fig = make_subplots(1, 2) +fig.add_trace(go.Bar(x=[1, 2, 3], y=[4, 5, 6], + marker=dict(color=[4, 5, 6], coloraxis="coloraxis1")), + 1, 1) +fig.add_trace(go.Bar(x=[1, 2, 3], y=[2, 3, 5], + marker=dict(color=[2, 3, 5], coloraxis="coloraxis1")), + 1, 2) +fig.update_layout(coloraxis=dict(colorscale='Bluered_r'), showlegend=False) +fig.show() +``` + #### Custom Sized Subplot with Subplot Titles 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. From ebf4ba5953333ab396fd734c4bd066522c5f64c8 Mon Sep 17 00:00:00 2001 From: Sylwia Mielnicka Date: Thu, 27 Feb 2020 09:09:30 +0100 Subject: [PATCH 2/2] Update subplots.md added shared_yaxes=True and some spacing for better readability in the section 'Subplots with Shared Colorscale' --- doc/python/subplots.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/doc/python/subplots.md b/doc/python/subplots.md index d0e268d173..50cf161d45 100644 --- a/doc/python/subplots.md +++ b/doc/python/subplots.md @@ -303,13 +303,17 @@ To share colorscale information in multiple subplots, you can use [coloraxis](ht ```python from plotly.subplots import make_subplots import plotly.graph_objects as go -fig = make_subplots(1, 2) + +fig = make_subplots(rows=1, cols=2, shared_yaxes=True) + fig.add_trace(go.Bar(x=[1, 2, 3], y=[4, 5, 6], - marker=dict(color=[4, 5, 6], coloraxis="coloraxis1")), + marker=dict(color=[4, 5, 6], coloraxis="coloraxis")), 1, 1) + fig.add_trace(go.Bar(x=[1, 2, 3], y=[2, 3, 5], - marker=dict(color=[2, 3, 5], coloraxis="coloraxis1")), + marker=dict(color=[2, 3, 5], coloraxis="coloraxis")), 1, 2) + fig.update_layout(coloraxis=dict(colorscale='Bluered_r'), showlegend=False) fig.show() ```