Reputation: 281
With ggplot2, it is really easy to plot a line with two colours, based on the value of the "col" variable, but is it possible to plot a line with the left part with one width and the right part with another one ?
Upvotes: 1
Views: 1787
Reputation: 98449
You get different width for the lines if you use the size=
argument inside the aes()
and set it to variable that divides your data.
The look of the plot will depend on variable that divides your data in groups.
If the variable is factors then you will get gap between parts of lines.
df1<-data.frame(x=1:10,y=1:10,z=rep(c("a","b"),each=5))
ggplot(df1,aes(x,y,size=z))+geom_line()
If the variable is numeric then there will be no gap.
df2<-data.frame(x=1:10,y=1:10,z=c(1,1,1,2,2,2,3,3,4,4))
ggplot(df2,aes(x,y,size=z))+geom_line()
Upvotes: 1