Skip to content

Commit 8335977

Browse files
committed
Add colorbar options to coloraxis.colorbar instead of to individual figures
1 parent 2b42d85 commit 8335977

File tree

1 file changed

+2
-20
lines changed

1 file changed

+2
-20
lines changed

Diff for: packages/python/plotly/templategen/utils/__init__.py

+2-20
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,6 @@
2929
]
3030

3131

32-
def set_all_colorbars(template, colorbar):
33-
for parent_path in colorscale_parent_paths:
34-
if not template.data[parent_path[0]]:
35-
template.data[parent_path[0]] = [{}]
36-
37-
for trace in template.data[parent_path[0]]:
38-
parent = trace[parent_path[1:]]
39-
40-
if "colorbar" in parent:
41-
parent.colorbar = colorbar
42-
43-
4432
def initialize_template(
4533
annotation_defaults,
4634
axis_common,
@@ -82,10 +70,11 @@ def initialize_template(
8270
template.layout.plot_bgcolor = panel_background_clr
8371
template.layout.polar.bgcolor = panel_background_clr
8472
template.layout.ternary.bgcolor = panel_background_clr
85-
set_all_colorbars(template, colorbar_common)
73+
8674
cartesian_axis = dict(axis_common, zerolinecolor=zerolinecolor_clr)
8775

8876
# Colorscales
77+
template.layout.coloraxis.colorbar = colorbar_common
8978
template.layout.colorscale.sequential = colorscale
9079
if colorscale_minus is not None:
9180
template.layout.colorscale.sequentialminus = colorscale_minus
@@ -95,13 +84,6 @@ def initialize_template(
9584
if colorscale_diverging is not None:
9685
template.layout.colorscale.diverging = colorscale_diverging
9786

98-
template.data.heatmap[0].colorscale = colorscale
99-
template.data.histogram2d[0].colorscale = colorscale
100-
template.data.histogram2dcontour[0].colorscale = colorscale
101-
template.data.contour[0].colorscale = colorscale
102-
template.data.surface[0].colorscale = colorscale
103-
template.data.heatmapgl[0].colorscale = colorscale
104-
10587
# Cartesian
10688
template.layout.xaxis = cartesian_axis
10789
template.layout.yaxis = cartesian_axis

0 commit comments

Comments
 (0)