When creating density heatmaps / 2d histograms, there is an automatic aggregation that can take place, which also sets the name as it appears on the legend. I'm trying to change how that aggregation is displayed on the legend. Consider the following example, taken directly from the plotly docs: import plotly.express as px df = px.data.tips() fig = px.density_heatmap(df, x="total_bill", y="tip") fig.show() How can I pass a string that will alter the "count" as it appears on the legend? I've tried with .update_layout(legend_title_text = "Test string") but did not manage to get anywhere. Continue reading...