在ggplot2中为geom_label设置“基本大小”,以便仍可读取最小值

时间:2018-12-25 15:24:35

标签: 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

谢谢!

1 个答案:

答案 0 :(得分:3)

确实有一种使用scale_sizerange参数的方法:

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