Percentage of Row Total in Heatmap Python

Question:

I would like to show the numbers as percentage of Row (or Column) Total for this heatmap. I am using Plotly library for the plotting.
enter image description here

I could find a way to get the percentage of row total using code below. I would really appreciate any help to plot these percentages in a heatmap for better visualisation.

enter image description here

Asked By: Gargi Nirmal

||

Answers:

You can use px.imshow() to create a heatmap for your dataframe such that:

import plotly.express as px
fig = px.imshow(pivotdf_unstack, text_auto=True, aspect="auto")
fig.show()

You can replace the null values with any suitable values you think.
You will get a heatmap with null values like:

enter image description here

Answered By: Hamzah
Categories: questions Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.