小编N. *_*nov的帖子

R 中的 ggplot2:在绘图和下划线文本之外进行注释

几个小时以来,我一直在挠头。我现在所拥有的:

library(ggplot2)
library(grid)

all_data = data.frame(country=rep(c("A","B","C","D"),times=1,each=20),
                  value=rep(c(10,20,30,40),times=1,each=20),
                  year = rep(seq(1991,2010),4))


# PLOT GRAPH

p1 <- ggplot() + theme_bw() + geom_line(aes(y = value, x = year, 
colour=country), size=2,
                                    data = all_data, stat="identity") + 
theme(plot.title = element_text(size=18,hjust = -0.037), legend.position="bottom", 
    legend.direction="horizontal", legend.background = element_rect(size=0.5, linetype="solid", colour ="black"),
    legend.text = element_text(size=16,face = "plain"), panel.grid.major = element_blank(), panel.grid.minor = element_blank(),
    panel.border = element_blank(),axis.line = element_line(colour = "black"),legend.title = element_blank(),
    axis.text=element_text(size=18,face = "plain"),axis.title.x=element_text(size=18,face = "plain", hjust = 1,
                                                                             margin = margin(t = 10, r = …
Run Code Online (Sandbox Code Playgroud)

r annotate ggplot2 geom-text

3
推荐指数
1
解决办法
5072
查看次数

标签 统计

annotate ×1

geom-text ×1

ggplot2 ×1

r ×1