Repository: plotly/plotly.py

Issue:
Update themes to use new layout-level colorscale defaults for Plotly.js 1.43.0
Update built-in themes to specify theme colorscales using the new `layout` level colorscale properties. (https://github.com/plotly/plotly.js/pull/3274). This will significantly reduce the theme sizes.


Discussion:

Resolving patch:
diff --git a/templategen/definitions.py b/templategen/definitions.py
--- a/templategen/definitions.py
+++ b/templategen/definitions.py
@@ -224,6 +224,20 @@ def seaborn():
 
 jupyterlab_output_clr = 'rgb(17,17,17)'
 
+plotly_diverging = [
+        [0, '#8e0152'],
+        [0.1, '#c51b7d'],
+        [0.2, '#de77ae'],
+        [0.3, '#f1b6da'],
+        [0.4, '#fde0ef'],
+        [0.5, '#f7f7f7'],
+        [0.6, '#e6f5d0'],
+        [0.7, '#b8e186'],
+        [0.8, '#7fbc41'],
+        [0.9, '#4d9221'],
+        [1, '#276419'],
+]
+
 
 def plotly():
     # Define colors
@@ -278,6 +292,7 @@ def plotly():
         colorway=colorway,
         colorbar_common=colorbar_common,
         colorscale=colorscale,
+        colorscale_diverging=plotly_diverging,
         axis_common=axis_common,
         annotation_defaults=annotation_defaults,
         shape_defaults=shape_defaults
@@ -352,6 +367,7 @@ def plotly_white():
         colorway=colorway,
         colorbar_common=colorbar_common,
         colorscale=colorscale,
+        colorscale_diverging=plotly_diverging,
         axis_common=axis_common,
         annotation_defaults=annotation_defaults,
         shape_defaults=shape_defaults
@@ -434,6 +450,7 @@ def plotly_dark():
         colorway=colorway,
         colorbar_common=colorbar_common,
         colorscale=colorscale,
+        colorscale_diverging=plotly_diverging,
         axis_common=axis_common,
         annotation_defaults=annotation_defaults,
         shape_defaults=shape_defaults
@@ -488,11 +505,6 @@ def presentation():
     # Increase global font size by 1.5x (12->18)
     template.layout.font.size = 18
 
-    # Set automargin to true in case we need to adjust margins for
-    # larger font size
-    template.layout.xaxis.automargin = True
-    template.layout.yaxis.automargin = True
-
     # Increase scatter markers and lines by 1.5x
     opts = {'marker': {'size': 9}, 'line': {'width': 3}}
     template.data.scatter = [opts]
diff --git a/templategen/utils/__init__.py b/templategen/utils/__init__.py
--- a/templategen/utils/__init__.py
+++ b/templategen/utils/__init__.py
@@ -29,18 +29,6 @@
 ]
 
 
-def set_all_colorscales(template, colorscale):
-    for parent_path in colorscale_parent_paths:
-        if not template.data[parent_path[0]]:
-            template.data[parent_path[0]] = [{}]
-
-        for trace in template.data[parent_path[0]]:
-            parent = trace[parent_path[1:]]
-            if 'colorscale' in parent:
-                parent.colorscale = colorscale
-                parent.autocolorscale = False
-
-
 def set_all_colorbars(template, colorbar):
     for parent_path in colorscale_parent_paths:
         if not template.data[parent_path[0]]:
@@ -67,7 +55,9 @@ def initialize_template(annotation_defaults,
                         table_cell_clr,
                         table_header_clr,
                         table_line_clr,
-                        zerolinecolor_clr):
+                        zerolinecolor_clr,
+                        colorscale_minus=None,
+                        colorscale_diverging=None):
 
     # Initialize template
     # -------------------
@@ -84,14 +74,33 @@ def initialize_template(annotation_defaults,
     template.layout.plot_bgcolor = panel_background_clr
     template.layout.polar.bgcolor = panel_background_clr
     template.layout.ternary.bgcolor = panel_background_clr
-    set_all_colorscales(template, colorscale)
     set_all_colorbars(template, colorbar_common)
     cartesian_axis = dict(axis_common, zerolinecolor=zerolinecolor_clr)
 
+    # Colorscales
+    template.layout.colorscale.sequential = colorscale
+    if colorscale_minus is not None:
+        template.layout.colorscale.sequentialminus = colorscale_minus
+    else:
+        template.layout.colorscale.sequentialminus = colorscale
+
+    if colorscale_diverging is not None:
+        template.layout.colorscale.diverging = colorscale_diverging
+
+    template.data.heatmap[0].autocolorscale = True
+    template.data.histogram2d[0].autocolorscale = True
+    template.data.histogram2dcontour[0].autocolorscale = True
+    template.data.contour[0].autocolorscale = True
+
     # Cartesian
     template.layout.xaxis = cartesian_axis
     template.layout.yaxis = cartesian_axis
 
+    # Set automargin to true in case we need to adjust margins for
+    # larger font size
+    template.layout.xaxis.automargin = True
+    template.layout.yaxis.automargin = True
+
     # 3D
     axis_3d = dict(cartesian_axis)
     if panel_background_clr:


Test patch: