I'm working in python with plotly, trying to have two heatmap subplot with a custom legend for each. But here what I see with the following code :
import plotly
fig = plotly.subplots.make_subplots(rows=2, cols=1)
mat = np.array([[1,0],
[0,1]])
fig.add_trace(go.Heatmap(z=mat, colorscale='Bluered_r'), row=1, col=1)
fig.add_trace(go.Heatmap(z=mat*10, colorscale='Bluered_r'), row=2, col=1)
fig.show()

you can see that both legend are displayed at the same place.
Thanks for your help!
Just found a solution hidden in the doc using the colorbar argument:
import plotly
fig = plotly.subplots.make_subplots(rows=2, cols=1)
mat = np.array([[1,0],
[0,1]])
fig.add_trace(go.Heatmap(z=mat, colorscale='Bluered_r',colorbar=dict(y=.8,len=.5)), row=1, col=1)
fig.add_trace(go.Heatmap(z=mat*10, colorscale='Bluered_r',colorbar=dict(y=.2,len=.5)), row=2, col=1)
fig.show()
This would give:

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With