gpt4 book ai didi

r - ggplot特定粗线

转载 作者:行者123 更新时间:2023-12-01 18:34:56 24 4
gpt4 key购买 nike

如何才能绘制出比另一条线更粗的线。我尝试使用 geom_line(size=X) ,但这会增加两条线的粗细。假设我想增加第一列的厚度,如何才能实现这一点?

a <- (cbind(rnorm(100),rnorm(100)))  #nav[,1:10]
sa <- stack(as.data.frame(a))
sa$x <- rep(seq_len(nrow(a)), ncol(a))
require("ggplot2")
p<-qplot(x, values, data = sa, group = ind, colour = ind, geom = "line")
p + theme(legend.position = "none")+ylab("Millions")+xlab("Age")+
geom_line( size = 1.5)

最佳答案

您需要将线条粗细映射到变量:

p + geom_line(aes(size = ind))

enter image description here

要控制厚度,请使用scale_size_manual():

p + geom_line(aes(size = ind)) +
scale_size_manual(values = c(0.1, 1))

enter image description here

关于r - ggplot特定粗线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17996410/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com