Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/26.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
Python yticks旋转参数从Seaborn热图中删除帧_Python_Matplotlib_Plot_Seaborn_Heatmap - Fatal编程技术网

Python yticks旋转参数从Seaborn热图中删除帧

Python yticks旋转参数从Seaborn热图中删除帧,python,matplotlib,plot,seaborn,heatmap,Python,Matplotlib,Plot,Seaborn,Heatmap,当我传递参数plt.yticksrotation=0时,我的热图将丢失其帧边。设置yticklabels=True无效 如何防止左边框丢失 使用该函数并丢失左帧: 如果不使用该功能并将旋转设置为90,则会产生保持帧的结果: 代码: import matplotlib.pyplot as plt import pandas as pd import seaborn as sns fig, ax = plt.subplots(figsize=(7.5,4.5)) excel_file

当我传递参数plt.yticksrotation=0时,我的热图将丢失其帧边。设置yticklabels=True无效

如何防止左边框丢失

使用该函数并丢失左帧:

如果不使用该功能并将旋转设置为90,则会产生保持帧的结果:

代码:

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

fig, ax = plt.subplots(figsize=(7.5,4.5)) 
excel_file          = r"C:\some\path\to\a\spreadsheet.xlsx"
xl                  = pd.ExcelFile(excel_file)
df                  = xl.parse((xl.sheet_names)[0])
df["Percentage"]    = df["Percentage"].apply(lambda x: round(x * 100, 2))
df["Overlap Count"] = df["Overlap"]
intersects          = df.pivot("Ward", "Overlap Count", "Percentage")
ax = sns.heatmap(intersects, linewidths = 0.1, cmap = "gray_r", linecolor = "black", edgecolor = "b")
plt.yticks(rotation = 0)
ax.invert_yaxis()
数据:

重复上述评论作为回答:


尝试在热图调用中设置clip_on=False。

可以吗?@ImportanceOfBeingErnest数据已添加类似df=pd.DataFramenumpy.random.rand8,12的内容。不允许复制此内容?无论如何,尝试在热图调用中设置clip_on=False。@ImportanceOfBeingErnest请将clip_on=False标记为正确答案
Ward Overlap Percentage
1   0   0.009222
2   0   0.152653
3   0   0.30053
4   0   0.360239
5   0   0.18537
6   0   0.026462
7   0   0.063586
8   0   0.276085
1   1   0.02033
2   1   0.081188
3   1   0.226472
4   1   0.147386
5   1   0.161132
6   1   0.043077
7   1   0.213306
8   1   0.110658
1   2   0.010786
2   2   0.103747
3   2   0.202578
4   2   0.144904
5   2   0.182761
6   2   0.047456
7   2   0.163646
8   2   0.11166
1   3   0.021125
2   3   0.064839
3   3   0.120019
4   3   0.0945
5   3   0.136404
6   3   0.038833
7   3   0.188478
8   3   0.127329
1   4   0.028342
2   4   0.079106
3   4   0.083844
4   4   0.05823
5   4   0.091276
6   4   0.089948
7   4   0.131098
8   4   0.116538
1   5   0.061603
2   5   0.070535
3   5   0.04057
4   5   0.057444
5   5   0.078471
6   5   0.093779
7   5   0.105894
8   5   0.125726
1   6   0.077076
2   6   0.090837
3   6   0.024996
4   6   0.050841
5   6   0.063669
6   6   0.133617
7   6   0.066882
8   6   0.073919
1   7   0.105353
2   7   0.12705
3   7   0.000991
4   7   0.042617
5   7   0.057453
6   7   0.148017
7   7   0.042073
8   7   0.044024
1   8   0.163147
2   8   0.077301
3   8   0
4   8   0.018129
5   8   0.032641
6   8   0.171143
7   8   0.019979
8   8   0.014061
1   9   0.17952
2   9   0.066654
3   9   0
4   9   0.008686
5   9   0.008022
6   9   0.127626
7   9   0.005059
8   9   0
1   10  0.139758
2   10  0.031035
3   10  0
4   10  0.009222
5   10  0.002765
6   10  0.039951
7   10  0
8   10  0
1   11  0.115179
2   11  0.038788
3   11  0
4   11  0.005554
5   11  3.64E-05
6   11  0.033801
7   11  0
8   11  0
1   12  0.06856
2   12  0.016265
3   12  0
4   12  0.002247
5   12  0
6   12  0.006292
7   12  0
8   12  0