r - 在 ggplot2 中为 geom_label 设置 "basic size",以便最小值仍然可读

标签 r ggplot2

我想在 geom_label 中使用“尺寸”作为美学.我的问题是最小标签尺寸太小以至于相应的标签几乎无法阅读。

在使用尺寸美学时,有没有办法设置“最小尺寸”之类的东西?如果有办法,它也应该可以指定最大标签大小,对吗?

我试过 theme_minimal(base_size = 15) ,但这会改变图中的所有尺寸。

小的可复制示例:

library(ggplot2)

data <- data.frame(title = c("too small!!!", "just right", "quite big"),
                   x.value = 1:3,
                   y.value = 1:3,
                   size.value = c(1, 5, 10))
ggplot(data, aes(x = x.value, y = y.value, size = size.value, label = title)) +
  geom_label()

Example plot with the label in the lower-left too small

谢谢!

最佳答案

确实有一种使用 scale_size 的方法和 range范围:

ggplot(data, aes(x = x.value, y = y.value, size = size.value, label = title)) +
  geom_label() + scale_size(range = c(0.5, 6))

enter image description here

关于r - 在 ggplot2 中为 geom_label 设置 "basic size",以便最小值仍然可读,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53923597/

相关文章:

r - geom_point 图例颜色具有倒置的形状覆盖而不是实际形状

r - 连接点

r - 如何调整在ggplot2中绘制轴的程度?

r - 使用 magrittr 管道转发运算符两次传递参数

r - 在rvest中使用submit_form

r - 如何 "concatenate"同时定义一个变量

r - 如何在 ggplot2 中的 x 轴下方添加注释?

r - 如何增加ggplot中*旋转* y轴上文本和标题之间的距离?

r - 在 R 中生成随机整数对而不进行替换

r - 数据帧上下文中的模式匹配