Plotting heatmap PlotlyJS, double bar

Hi, I am plotting heatmap subplots using PlotlyJS package and get the problem of the bar being double. The input into the heatmap is just values of either 1, 2 or 3. I assume a part of the problem is some plots only take in two of these and that’s why the top of the bar is both 2 and 3. Does any one know how to fix this problem?
plot from model

I feel like the answer could be in here in the part about ticktext/tickvals, but not able to understand it: Heatmap traces in Julia

Your subplot of heatmaps seems to be defined in order to compare Decision rule at different times.
A definition of subplots like this one, associates colorbar tickvals for each heatmap:

using PlotlyJS

fig1 = make_subplots(rows=1, cols=2)
add_trace!(fig1, heatmap(x=1:5, y=1:4, z=rand(2:7, 4,5)), row=1, col=1)
add_trace!(fig1, heatmap(x=1:4, y=1:4, z=rand(4:10, 4,4)), row=1, col=2)
relayout!(fig1, width=700, height=350)
display(fig1)

but if you are referencing each heatmap to the same coloraxis, i.e. a unique colorbar with zmin=min(of the values in the union of z-values of both heatmaps),
and zmax=max (the same values as for zmin), then you also get unique tickvals for the colorbar:

fig2 = make_subplots(rows=1, cols=2)
add_trace!(fig2, heatmap(x=1:5, y=1:4, z=rand(2:7, 4,5), coloraxis="coloraxis"), row=1, col=1)
add_trace!(fig2, heatmap(x=1:4, y=1:4, z=rand(4:10, 4,4), coloraxis="coloraxis"), row=1, col=2)
relayout!(fig2, width=700, height=350)
display(fig2)

2 Likes

Thanks! This helped adding values for z in there. Now I did like this for every subplot and the bar is fine:

data = decision_rule[:, :, 5, 1, timestep]
    add_trace!(p, heatmap(z=data, y=0:1:20, x=0:1:20, zmin=1, zmax=3), row=1, col=1)