简体   繁体   English

Plotly Express 热图无法正常工作

[英]Plotly Express Heatmap not working properly

I'm a newbie in Python and i need your help for solving this tricky problem.. I created an heatmap graph with seaborn in order to show Project Managers allocation on projects, and it's owrking properly.我是 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"

在此处输入图像描述

I tried to create the same graph with the same data with plotly express, but it seems that it doesn't represent all the data.我尝试使用 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()

在此处输入图像描述

Sample Data 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示例数据 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

Can you please help me?你能帮我么?

Solved.解决了。 The spike_cols list was not sorted. peak_cols 列表未排序。 After sorting it works.排序后就可以了。

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

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