是否可以绘制不同大小(即粗)的线geom_line
?
所有行的大小参数都相同,与组无关:
bp <- ggplot(data=diamonds, aes(x=cut, y=depth)) +
geom_line(aes(color=cut), size=1)
但是,我希望线条的粗细能够反映它们作为观察次数测量的相对重要性:
relative_size <- table(diamonds$cut)/nrow(diamonds)
bp <- ggplot(data=diamonds, aes(x=cut, y=depth)) +
geom_line(aes(color=cut), size=cut)
bp
# Error: Incompatible lengths for set aesthetics: size
有趣的是,geom_line(..., size=cut)
它可以工作,但并不像预期的那样,因为它根本不会改变线的大小。