Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/80.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R:ggplot2更改注释中文本周围框的边距(geom=";label";…)_R_Ggplot2_Annotate - Fatal编程技术网

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"))    # <------------