From 10271ff7d2830db5cd4f32cf8565ea5eef96b7cf Mon Sep 17 00:00:00 2001 From: joelostblom Date: Tue, 5 Nov 2019 10:50:24 +0100 Subject: [PATCH 1/5] Use the default template's background for swatches Instead of always using the plotly template --- packages/python/plotly/_plotly_utils/colors/_swatches.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/python/plotly/_plotly_utils/colors/_swatches.py b/packages/python/plotly/_plotly_utils/colors/_swatches.py index ff07ff42907..6e65d505555 100644 --- a/packages/python/plotly/_plotly_utils/colors/_swatches.py +++ b/packages/python/plotly/_plotly_utils/colors/_swatches.py @@ -2,7 +2,8 @@ def _swatches(module_names, module_contents): """ Returns: A `Figure` object. This figure demonstrates the color scales and - sequences in this module, as stacked bar charts. + sequences in this module as stacked bar charts against the default + template's background. """ import plotly.graph_objs as go @@ -28,7 +29,6 @@ def _swatches(module_names, module_contents): title=module_names, barmode="stack", barnorm="fraction", - template="plotly", bargap=0.5, showlegend=False, xaxis=dict(range=[-0.02, 1.02], showticklabels=False, showgrid=False), From 3d41f3f7ec49e856a58152833541e68b5d90caef Mon Sep 17 00:00:00 2001 From: joelostblom Date: Wed, 6 Nov 2019 06:13:43 +0100 Subject: [PATCH 2/5] Use bgcolor from px.defaults.template --- packages/python/plotly/_plotly_utils/colors/_swatches.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/python/plotly/_plotly_utils/colors/_swatches.py b/packages/python/plotly/_plotly_utils/colors/_swatches.py index 6e65d505555..c5f4a8db294 100644 --- a/packages/python/plotly/_plotly_utils/colors/_swatches.py +++ b/packages/python/plotly/_plotly_utils/colors/_swatches.py @@ -6,6 +6,7 @@ def _swatches(module_names, module_contents): template's background. """ import plotly.graph_objs as go + import plotly.express as px sequences = [ (k, v) @@ -29,6 +30,7 @@ def _swatches(module_names, module_contents): title=module_names, barmode="stack", barnorm="fraction", + template=px.defaults.template, bargap=0.5, showlegend=False, xaxis=dict(range=[-0.02, 1.02], showticklabels=False, showgrid=False), From 10a08671e7497e42012001a32247393cc4070c76 Mon Sep 17 00:00:00 2001 From: joelostblom Date: Wed, 6 Nov 2019 06:15:45 +0100 Subject: [PATCH 3/5] Use height and width from px.defaults --- packages/python/plotly/_plotly_utils/colors/_swatches.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/python/plotly/_plotly_utils/colors/_swatches.py b/packages/python/plotly/_plotly_utils/colors/_swatches.py index c5f4a8db294..8a9f7e28c1f 100644 --- a/packages/python/plotly/_plotly_utils/colors/_swatches.py +++ b/packages/python/plotly/_plotly_utils/colors/_swatches.py @@ -34,6 +34,7 @@ def _swatches(module_names, module_contents): bargap=0.5, showlegend=False, xaxis=dict(range=[-0.02, 1.02], showticklabels=False, showgrid=False), - height=max(600, 40 * len(sequences)), + height=max(px.defaults.height, 40 * len(sequences)), + width=px.defaults.width ), ) From d291d3a125f2308cb6b76a41d361674dced38d92 Mon Sep 17 00:00:00 2001 From: joelostblom Date: Wed, 6 Nov 2019 18:12:15 +0100 Subject: [PATCH 4/5] Clean up titles --- packages/python/plotly/_plotly_utils/colors/_swatches.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/python/plotly/_plotly_utils/colors/_swatches.py b/packages/python/plotly/_plotly_utils/colors/_swatches.py index 8a9f7e28c1f..60a2bc2336f 100644 --- a/packages/python/plotly/_plotly_utils/colors/_swatches.py +++ b/packages/python/plotly/_plotly_utils/colors/_swatches.py @@ -27,7 +27,7 @@ def _swatches(module_names, module_contents): for name, colors in reversed(sequences) ], layout=dict( - title=module_names, + title=module_names.split('.')[-1].capitalize() + ' colorscales', barmode="stack", barnorm="fraction", template=px.defaults.template, From 17c35ef8d95111fdc21b377cf9b7f911315ab68d Mon Sep 17 00:00:00 2001 From: joelostblom Date: Wed, 6 Nov 2019 18:20:01 +0100 Subject: [PATCH 5/5] Blacken --- packages/python/plotly/_plotly_utils/colors/_swatches.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/python/plotly/_plotly_utils/colors/_swatches.py b/packages/python/plotly/_plotly_utils/colors/_swatches.py index 60a2bc2336f..5bb311f5c3a 100644 --- a/packages/python/plotly/_plotly_utils/colors/_swatches.py +++ b/packages/python/plotly/_plotly_utils/colors/_swatches.py @@ -27,7 +27,7 @@ def _swatches(module_names, module_contents): for name, colors in reversed(sequences) ], layout=dict( - title=module_names.split('.')[-1].capitalize() + ' colorscales', + title=module_names.split(".")[-1].capitalize() + " colorscales", barmode="stack", barnorm="fraction", template=px.defaults.template, @@ -35,6 +35,6 @@ def _swatches(module_names, module_contents): showlegend=False, xaxis=dict(range=[-0.02, 1.02], showticklabels=False, showgrid=False), height=max(px.defaults.height, 40 * len(sequences)), - width=px.defaults.width + width=px.defaults.width, ), )