我想突出显示ggplot的注释表中每列的最大值.最好的结果是如果结果是一个ggplot,我可以在其余代码中使用它.
使用ggpmisc包的annotate(.)方法,我可以使用添加的表创建一个图
library(ggplot2)
library(ggpmisc)
gg1 <- ggplot(iris, aes(Sepal.Length, Petal.Length, color = Species) ) +
geom_point() +
annotate(geom = "table",
x = Inf, y = 0,
label = list(head(iris,5 )),
size=2)
gg1
我找到了这个答案,我对其进行了修改,以突出显示列而不是行的最大值: https://stackoverflow.com/a/72430256
library(ggplot2)
library(flextable)
library(magrittr)
iris %>%
flextable::flextable() -> iris_max_highlight
for(i in seq_len(ncol(iris)))
{
iris_max_highlight %<>% flextable::bold(which.max(iris[,i]), i)
}
iris_max_highlight
然后我试图以某种方式将结果与这个答案结合起来,将修改后的表添加到图中,但无法让它发挥作用:https://stackoverflow.com/a/60350244