Heatmap coloring relative to table row

Hi guys!

I have a question about setting the color scheme for Plotly heatmaps. What I need is to show the dates (quarterly) on the x-axis and have several economic indicators on the y-axis. I can find a way to do this in the documentation.

However, I was wondering if there’s any way to set the color strength for each row individually, relative to the values in the respective row. Something similar to the heatmap in this Excel worksheet:

Capture

Any suggestions would be much appreciated!

Hi there,
You can set the value of each colour individually using the “z” argument in your plotly heatmap function.
You’ll find a good example here : https://plot.ly/python/heatmaps/ at the " Heatmap with Datetime Axis" part.
And the heatmap function reference there : https://plot.ly/python/reference/#heatmap

Problem is that is not what I am trying to do. I am trying to have the color scale as a %, so that on each row the lowest value (from that row) takes the lightest color and the highest value (from that row) takes the darkest color. See the pic in the questions. Thanks so much @Ncohen

I don’t think there’s a built-in way to do that - but if you can adjust the z values to normalize each row yourself, you could include the raw values in text, along with perhaps hoverinfo='x+y+text' if you want to hide the normalized values from hover labels.

Thank you very much @alexcjohnson. Solved the problem.

1 Like