I have a Figure with two Heatmap subplots below. Each subplot has its own coloraxis: coloraxis1
and coloraxis2
. However I cannot get the final figure to hide the colorbar.
Also, when I try to set coloraxis2_showscale=False
in fig.update_layout()
I get an error.
ValueError: Invalid property specified for object of type plotly.graph_objs.Layout: 'coloraxis2'
Can you help me?
import plotly.graph_objects as go
from plotly.subplots import make_subplots
import numpy as np
# Generate some random data for heatmaps
z1 = np.random.rand(10, 10)
z2 = np.random.rand(10, 10)
# Create subplots with separate color axes
fig = make_subplots(rows=1, cols=2, subplot_titles=("Heatmap 1", "Heatmap 2"))
# Add first heatmap to the first subplot with its own color axis
heatmap1 = go.Heatmap(z=z1, coloraxis='coloraxis1', showscale=False)
fig.add_trace(heatmap1, row=1, col=1)
# Add second heatmap to the second subplot with its own color axis
heatmap2 = go.Heatmap(z=z2, coloraxis='coloraxis2', showscale=False)
fig.add_trace(heatmap2, row=1, col=2)
# Update layout to define separate color axes
fig.update_layout(coloraxis1_showscale=False)
# Show plot
fig.show()