R:ggplot2更改注释中文本周围框的边距(geom=";label";…)
有没有办法控制文本周围框的边距大小R:ggplot2更改注释中文本周围框的边距(geom=";label";…),r,ggplot2,annotate,R,Ggplot2,Annotate,有没有办法控制文本周围框的边距大小 x <- data.frame(x = c(5, 10), y = c(0.5, 1)) ggplot(data=x, aes(x, y)) + geom_bar(stat = 'identity', fill=c("red4","cornflowerblue"))+ annotate(geom= "label", x=5, y=.6, label="Just\ntext\n
x <- data.frame(x = c(5, 10), y = c(0.5, 1))
ggplot(data=x, aes(x, y)) +
geom_bar(stat = 'identity', fill=c("red4","cornflowerblue"))+
annotate(geom= "label", x=5, y=.6, label="Just\ntext\nhere\nwith\ndifferent\nmargins", size=5)
x有参数label.padding
。看
ggplot(数据=x,aes(x,y))+
几何图形条(stat='identity',fill=c(“红色4”,“矢车菊蓝”)+
注释(geom=“label”,x=5,y=0.6,
label=“Just\ntext\n带有\n不同的\n边缘”,大小=5,
label.padding=unit(4,“行”)#在调用annotate
时添加参数label.padding=unit(0.5,“行”)
。查看ggplot文档中的geom_标签
,了解控制标签的更多详细信息和参数。
ggplot(data=x, aes(x, y)) +
geom_bar(stat = 'identity', fill=c("red4","cornflowerblue")) +
annotate(geom= "label", x=5, y=.6,
label="Just\ntext\nhere\nwith\ndifferent\nmargins", size=5,
label.padding=unit(4, "lines")) # <------------