简体   繁体   English

热图中行总数的百分比 Python

[英]Percentage of Row Total in Heatmap Python

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.我正在使用 Plotly 库进行绘图。 在此处输入图像描述

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.我真的很感激任何帮助 plot 这些百分比在热图中以获得更好的可视化。

在此处输入图像描述

You can use px.imshow() to create a heatmap for your dataframe such that:您可以使用px.imshow()为您的 dataframe 创建一个热图,这样:

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.您可以将 null 值替换为您认为合适的任何值。 You will get a heatmap with null values like:您将获得一个包含 null 个值的热图,例如:

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM