我想在 facet_wrap 生成的图形上添加不同的注释。
我尝试了下面的代码,但它显示错误,例如“FUN(X [[i]],...)中的错误:找不到对象'值'”。
dat_text <- data.frame(
label = c("TRUE:FALSE = 686:324", "TRUE:FALSE = 976:34", "TRUE:FALSE = 516:494", "TRUE:FALSE = 360:650",
"TRUE:FALSE = 351:659", "TRUE:FALSE = 440:570", "TRUE:FALSE = 645:365", "TRUE:FALSE = 151:859", "TRUE:FALSE = 542:468"),
cyl = c(Agricultural_land, Artificial_land, Precipitation, Protected_area,
RiverLake, Seashore, Temperature, Volcanic_area, Wasteland)
)
z_cor <- fit01_zsize2 %>%
ggplot(aes(x = value_without, y = value_with, color = value))+
geom_point(shape = 1)+
geom_text(
data = dat_text,
mapping = aes(x = -Inf, y = -Inf, label = label),
hjust = -0.1,
vjust = -1
)+
geom_abline(intercept = 0, slope = 1, linetype = "dashed") +
scale_color_manual(values = c("TRUE" = "salmon", "FALSE" = "steelblue"))+
facet_wrap(.~variable1)+
theme(strip.text.x = element_text(size = 20),
axis.title=element_text(size=16))
plot(z_cor)
当我尝试没有 geom_text() 的相同代码时,它起作用了。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句