如何按组为corrplot的背景着色?
考虑这些数据,我们有几个组,每个组有10个观察值,我们进行了一次如何按组为corrplot的背景着色?,r,ggplot2,matrix,data-visualization,r-corrplot,R,Ggplot2,Matrix,Data Visualization,R Corrplot,考虑这些数据,我们有几个组,每个组有10个观察值,我们进行了一次成对.t.测试(): 有人知道根据分组标签给每个正方形的背景上色的方法吗?例如,假设我们希望组a:g的方块为黄色,组h:n的方块为蓝色,组o:r的方块为红色。或者是否有其他方法可以使用ggplot?您可以通过bg=参数传递背景色向量。诀窍在于确保它们的顺序正确。这是做这件事的方法 bgcolors <- matrix("white", nrow(pmat), ncol(pmat),dimnames = d
成对.t.测试()
:
有人知道根据分组标签给每个正方形的背景上色的方法吗?例如,假设我们希望组
a:g
的方块为黄色,组h:n
的方块为蓝色,组o:r
的方块为红色。或者是否有其他方法可以使用ggplot
?您可以通过bg=
参数传递背景色向量。诀窍在于确保它们的顺序正确。这是做这件事的方法
bgcolors <- matrix("white", nrow(pmat), ncol(pmat),dimnames = dimnames(pmat))
bgcolors[1:6, ] <- "yellow"
bgcolors[7:15, ] <- "blue"
bgcolors[14:17, ] <- "red"
bgcolors <- bgcolors[lower.tri(bgcolors, diag=TRUE)]
corrplot(pmat, insig = "blank", type = "lower", bg=bgcolors)
bgcolors替代方法当然可以是使用ggcorrplot
包()。
bgcolors <- matrix("white", nrow(pmat), ncol(pmat),dimnames = dimnames(pmat))
bgcolors[1:6, ] <- "yellow"
bgcolors[7:15, ] <- "blue"
bgcolors[14:17, ] <- "red"
bgcolors <- bgcolors[lower.tri(bgcolors, diag=TRUE)]
corrplot(pmat, insig = "blank", type = "lower", bg=bgcolors)