Reputation: 3393
I have this sample data:
head(output.melt,10)
month variable value LineSize
1 01 1997 100.00000 1
2 02 1997 91.84783 1
3 03 1998 92.67626 1
4 04 1998 105.70113 1
5 05 1998 115.12516 1
6 06 1998 118.95298 1
7 07 1999 117.99673 1
8 08 1999 125.50852 1
9 09 1999 119.39502 1
10 10 1999 100.79032 1
11 03 Mean 103.17473 2
12 04 Mean 108.12440 2
13 05 Mean 109.54016 2
14 06 Mean 107.71431 2
15 07 Mean 107.86694 2
16 08 Mean 108.32371 2
17 09 Mean 102.06684 2
18 10 Mean 99.96975 2
19 11 Mean 111.94529 2
20 12 Mean 113.49491 2
I want to make a plot where one line has different linetype
and size
. I get the different linetype
but not size
:
theplot=ggplot(data = output.melt, aes(x=month, y=value,colour=variable,group=variable,linetype = LineSize))
+geom_line()
+scale_linetype( guide="none")
+ggtitle(as.character("Hello"))+theme_economist()
But the code above does not make the line (where LineSize
is equal 2) wider then others, which I want. And adding size=LineSize
to aes creates an ugly graph.
Upvotes: 0
Views: 188
Reputation: 1311
As it was suggested in the comments you have to use following code:
theplot=ggplot(data = output.melt, aes(x=month, y=value,colour=variable,group=variable, size= as.numeric(LineSize)))
+geom_line()
+scale_linetype( guide="none")
+ggtitle(as.character("Hello"))
Keep in mind that size of a size = 2
is quite a lot so you would have to adjust your table.
Upvotes: 2