r - R:ggplot2 更改注释中文本框的边距(geom="label"...)
问题描述
有没有办法控制文本周围框的边距大小?
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)
解决方案
有参数label.padding
。请参阅文档。
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")) # <------------
推荐阅读
- c - C定义第一次不使用时扩展不一样的宏
- c - 通过引用错误传递结构(不完整的结构和重新声明)
- java - 如何按时间戳属性过滤对象数组(通过 - 命令替代 SQL 滞后于分区的代码)
- elasticsearch - 如何在多索引搜索中通过索引获取聚合聚合?
- python - 使用 tensorflow-distributed 实现 mask-r-cnn
- c# - 当列表视图中的项目很少时,标题列的右下角是什么?
- firebase - 使用 API 查询 Firebase A/B 测试
- java - 如何在 HashMap 中获取已排序的数组列表?
- c++ - 按名称查找进程ID的快速方法
- react-native - 被 props 调用后未将操作分派给减速器