2013-08-01 80 views
6

如何繪製一條線比另一條線更粗。我嘗試使用geom_line(size=X),但這樣會增加兩條線的粗細。假設我想增加第一列的厚度,那麼如何能夠接近這個呢?ggplot特定粗線

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) 
+0

你讀過joran的[這個答案](http://stackoverflow.com/a/10871142/1305688)嗎? –

回答

13

您需要線厚度映射到變量:

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