我想在热图单元上加上十字(X)(取决于显著性水平,但问题在于添加X)。在
就像R语言一样(信号电平=XXX)。在
请参阅使用的Python和R代码以及相应的输出图像。在
谢谢你的帮助。在
# Draw the heatmap with the mask and correct aspect ratio
sns.heatmap(corr, mask=mask, cmap=cmap, center=0, vmin=-1, vmax=1, square=True, linewidths=0.5, fmt=".2f",
cbar_kws={"shrink": .65, "orientation": "horizontal", "ticks":np.arange(-1, 1+1, 0.2)},
annot = True, annot_kws={"weight": 'bold', "size":15})
corrplot(cor(subset (wqw, select =
c(fixed.acidity:quality,ratio.sulfur.dioxide))),
# compute the p matrix
p.mat = cor.mtest(subset
(wqw, select = c(fixed.acidity:quality,ratio.sulfur.dioxide))),
# significance level 0.01
sig.level = 0.01,
# Method to display : color (could be corcle, ...)
method = "color",
# color palette
col = colorRampPalette(c("#BB4444", "#EE9988",
"#FFFFFF", "#77AADD", "#4477AA"))(200),
)
```
简单的解决方案是添加一个带有X形标记的散点图,以划掉不需要的单元格。在
这样做的缺点是markersize(
s
)与单元格的数量无关,需要根据不同的图形大小进行调整。在因此,另一种方法是在各自的位置绘制一些线(X是两条交叉线)。这里我们创建一个函数
^{pr2}$crossout(points, ax=None, scale=1, **kwargs)
,其中scale
是行从每个单元格中获得的百分比。在对于
scale=0.8
这看起来像注意对于一个
pcolormesh
图或一个海生热图(内部使用pcolormesh
),需要在数据中添加0.5
,即相关问题 更多 >
编程相关推荐