ggplot specific thick line

吃可爱长大的小学妹 提交于 2019-12-19 07:22:05

问题


How would one be able to plot one line thicker than the other. I tried using the geom_line(size=X) but then this increases the thickness of both lines. Let say I would like to increase the thickness of the first column, how would one be able to approach this?

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)

回答1:


You need to map line thickness to the variable:

p + geom_line(aes(size = ind))

To control the thickness use scale_size_manual():

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



来源:https://stackoverflow.com/questions/17996410/ggplot-specific-thick-line

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!