打印的数字的实际大小由scale_size_continuous
控制。该比例采用参数range
,该参数定义了用于最小和最大对象的尺寸。默认情况下,range = c(1,6)
。你可以用这两个数字来玩,直到你得到所需的结果。
默认值:
ggplot(mtcars, aes(carb)) +
stat_count(aes(y = ..count..),
show.legend = F, geom = "text") +
element_text(aes(size = ..count.., label = ..count..)) +
scale_size_continuous(range = c(1, 6))
放大小的数字,但保持最大尺寸相同:
ggplot(mtcars, aes(carb)) +
stat_count(aes(y = ..count..),
show.legend = F, geom = "text") +
element_text(aes(size = ..count.., label = ..count..)) +
scale_size_continuous(range = c(3, 6))
放大所有数字:
ggplot(mtcars, aes(carb)) +
stat_count(aes(y = ..count..),
show.legend = F, geom = "text") +
element_text(aes(size = ..count.., label = ..count..)) +
scale_size_continuous(range = c(4, 12))