Sorry if this question is too basic but I am a newbie to Plotly. I have a make_subplots
that has 2*2 heatmaps. I want those heatmap in same row share one colorbar. I tried it, but the colorbar_y is hard to specific, it depend our experience. Do you have any suggestions for me. More dynamic, or other methods.
def show_simu_map():
# Initialize figure with subplots
fig = make_subplots(
rows=2, cols=2,
specs=[[{"type": "heatmap"}, {"type": "heatmap"}],
[{"type": "heatmap"}, {"type": "heatmap"}]])
fig.add_trace(
go.Heatmap(
z=[[1, 20, 30],
[20, 1, 60],
[30, 60, 1]],
coloraxis="coloraxis1"),
row=1,col=1
)
fig.add_trace(
go.Heatmap(
z=[[1, 20, 30],
[20, 1, 60],
[30, 60, 1]],
coloraxis = "coloraxis1"
),
row=1,col=2
)
fig.add_trace(
go.Heatmap(
z=[[1, 20, 30],
[20, 1, 60],
[30, 60, 1]],
coloraxis="coloraxis2"
),
row=2,col=1
)
fig.add_trace(
go.Heatmap(
z=[[1, 20, 30],
[20, 1, 60],
[30, 60, 1]],
coloraxis = "coloraxis2"),
row=2,col=2
)
fig.update_layout(
coloraxis=dict(colorscale='jet', colorbar_y=0.75, colorbar_len=0.45, cmin=0, cmax=1.9),
coloraxis2=dict(colorscale='deep_r', colorbar_y=0.2, colorbar_len=0.45, cmin=0, cmax=1.9))
fig.show()