首页 > 解决方案 > Plotly Express 热图无法正常工作

问题描述

我是 Python 的新手,我需要你的帮助来解决这个棘手的问题。我用 seaborn 创建了一个热图,以显示项目经理在项目上的分配,并且它运行正常。

ax = sns.heatmap(result_grouped[spike_cols]*100, cmap=mycmap,vmin=0, vmax=200, linewidths=.05, 
linecolor='lightgray', cbar_kws={'label': '% ore giorno'}) #"YlGnBu"

在此处输入图像描述

我尝试使用 plotly express 创建具有相同数据的相同图表,但它似乎并不能代表所有数据。

import dash
import dash_core_components as dcc
import dash_html_components as html
import plotly.express as px
spike_cols = [col for col in result_grouped.columns if '2021-' in col]
fig = px.imshow(result_grouped[spike_cols],
                #x=spike_cols,
                y=result_grouped.index,
                 width=900, height=800
               )
fig.show()

在此处输入图像描述

示例数据 PM IT|17/02/2021|18/02/2021|19/02/2021|22/02/2021|23/02/2021|24/02/2021|25/02/2021|26/02 /2021 ito|0.753503|0.753503|0.752568|0.752568|0.752568|0.614762|0.610097|0.572597 nzi|0.716667|0.716667|0.716667|0.716667|0.716667|0.716667|0.658333|0.633333

你能帮我么?

标签: pythonplotlyheatmapplotly-express

解决方案


解决了。peak_cols 列表未排序。排序后就可以了。


推荐阅读