Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/308.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使Power Bi网站版本中的python图表与桌面版本中的类似?_Python_Matplotlib_Powerbi_Seaborn_Powerbi Custom Visuals - Fatal编程技术网

如何使Power Bi网站版本中的python图表与桌面版本中的类似?

如何使Power Bi网站版本中的python图表与桌面版本中的类似?,python,matplotlib,powerbi,seaborn,powerbi-custom-visuals,Python,Matplotlib,Powerbi,Seaborn,Powerbi Custom Visuals,我正在使用python和seaborn在Power Bi中准备热图。它在这个软件的桌面版本中看起来很好,但当我发布报告时,它会切割部分Y轴标签并改变图表的大小 Power Bi桌面: 在线报告: 这是我的密码: import matplotlib.pyplot as plt import seaborn as sns import pandas as pd import numpy as np if not dataset.empty: dataset['Skill Name']

我正在使用python和seaborn在Power Bi中准备热图。它在这个软件的桌面版本中看起来很好,但当我发布报告时,它会切割部分Y轴标签并改变图表的大小

Power Bi桌面:

在线报告:

这是我的密码:

import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd
import numpy as np

if not dataset.empty:
    dataset['Skill Name'] = dataset['Skill Name'].str.replace(r"\(.*\)","")
    dataset['Skill Name'] = dataset['Skill Name'].str.replace(r"\-\-.*","")

    skill_name_dir = {
        "including":"inc",
        "Documentation":"Doc",
        "Design":"Dsgn",
        "Process":"Proc",
        "Architecture":"Arch",
        "Frequency":"Freq",
        "Engineering":"Engr",
        "Hardware":"Hdw",
        "Software":"Sw",
        "Power":"Pwr",
        "Termination":"Term",
        "Electromechanical":"Elmech",
        "Requirements":"Req"
    }

    for word, initial in skill_name_dir.items():
        dataset['Skill Name'] = dataset['Skill Name'].str.replace(word,initial)

    dataset['Category'] = dataset['Category'].str.replace(r"^Domain[A-Za-z\s\S]*", "Dom", regex=True)
    dataset['Category'] = dataset['Category'].str.replace(r"^Process[A-Za-z\s\S]*", "Proc", regex=True)
    dataset['Category'] = dataset['Category'].str.replace(r"^Product[A-Za-z\s\S]*", "Prod", regex=True)
    dataset['Category'] = dataset['Category'].str.replace(r"^Tools[A-Za-z\s\S]*", "Tool", regex=True)
    dataset['Category'] = dataset['Category'].str.replace(r"^Organization[A-Za-z\s\S]*", "Org", regex=True)
    dataset['Category'] = "(" + dataset['Category'] + ")"

    dataset['Manager Name'] = dataset['Manager Name'].str.replace('[^A-Z]', '', regex=True)
    dataset['Manager Name'] = "(" + dataset['Manager Name'] + ")"
    dataset['Employee Name'] = dataset['Manager Name'] + dataset['Employee Name']

    dataset = dataset.sort_values(['Category', 'Skill Name', 'Employee Name'], ascending=[True, True, False])
    dataset['Skill Name'] = dataset['Category'] + dataset['Skill Name']
    dataset['Score'] = dataset['Score'].replace(-1,np.nan)

    heatmap_data = pd.pivot_table(dataset, values='Score', index=['Skill Name'], columns='Employee Name')

    #plt.figure(figsize=(30,15))
    fig = plt.gcf()
    figsize = fig.get_size_inches()
    fig.set_size_inches(figsize*1.4)

    hm = sns.heatmap(
        heatmap_data,
        vmin=0,
        vmax=5,
        #annot=True,
        linewidths=0.01,
        square=True,
        cmap="RdYlGn"
    )

    hm.xaxis.set_ticks_position('top')

    hm.set_xticklabels(
        hm.get_xticklabels(),
        rotation=60,
        horizontalalignment='left',
        fontsize = 7,
        wrap = True
    )

    hm.set_yticklabels(
        hm.get_yticklabels(),
        fontsize = 7,
        #wrap = True
    )
    hm.set_ylabel('')    
    hm.set_xlabel('')
else:
    fig = plt.figure(figsize=(5, 1.5))
    text = fig.text(0.5, 0.5, 'No data to display.\nPlease change filters \nto display chart.', ha='center', va='center', size=20)
plt.tight_layout()
plt.show()


你知道为什么图表和桌面版不同吗?

这个问题是由python的3.7版引起的。更改为3.5版修复了此问题。

能否添加桌面图片和在线图片的快照?您在什么设备上查看在线版本?我使用同一台笔记本电脑查看两个版本。快照附在上面