I have a matrix with which i am plotting the following plot.
As one could see the total row and column part of the plot dominates the colorscale which in turn diminishes the visual effect of other values. My goal is to remove the color scale from last row and column but i am unsure how to do it.
Here is my current plot code
def annotate_matrix_values(df: pd.DataFrame, fig: go.Figure) -> go.Figure:
df_matrix = df.to_records(index=False)
for i, r in enumerate(df_matrix):
for k, c in enumerate(r):
fig.add_annotation(
x=k,
y=i,
text=f"<b>{str(int(c))}</b>" if not math.isnan(c) else "",
showarrow=False,
)
fig.update_xaxes(side="top")
fig.update_coloraxes(showscale=False)
return fig
df_final = pd.crosstab(pt[y_axis_name], pt[x_axis_name], margins=True)
fig = px.imshow(
df_final,
labels=dict(x=x_title, y=y_title, color="Value"),
x=x_label,
y=y_label,
color_continuous_scale="Purples",
aspect="auto",
)
fig = annotate_matrix_values(df_final, fig)
Of course i can set margin false here and get the following plot. But then I cant show the totals.
df_final = pd.crosstab(pt[y_axis_name], pt[x_axis_name], margins=False)
So my goal is to show the totals but without any color scale on it. Thanks for the help





