How to hide colorbar in figure with independent coloraxes for each subplot

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()

Hey @rayne welcome to the forums.

If you remove the coloraxis from each heatmap, no scale is shown. What exactly do you want to achieve?

hey @AIMPED , thanks for the reply. I don’t want to remove coloraxis from each Heatmap because I want each heatmap to have it’s own coloraxis. As you can see in the output, even though I set showscale=False on each Heatmap, the colorscale is still shown on the right. I also set coloraxis1_showscale=False but the color scale is still there. I’d like to remove it from displaying while still having each heatmap get its own coloraxis.

OK, I actually think, you should coloraxis=coloraxis and coloraxis=coloraxis1

This would be in line with the y-axes naminc convention.