4

I have made multi facet ggplot using the facet_wrap function but could not find something that would let me create secondary y axis for a particular variable for all my plots.

I have tried looking in google and found http://rpubs.com/kohske/dual_axis_in_ggplot2 but i am not sure how to go from here to multi facet plots.

I melted the dataset to get to get the different facet plots but cant figure how to put in a secondary y axis for the particular variable in group.

fig4bplot<-    ggplot(fig4b,aes(x=as.Date(time),y=value,group=variable,color=variable))+geom_line(size=2,alph    a=4/5)+facet_wrap(~ Area)+theme_bw()
fig4bplot<-fig4bplot + theme(legend.position="bottom",legend.direction   ="vertical")+opts(axis.text.x = theme_text(angle = 90))
fig4bplot<-fig4bplot+xlab("Time")+ylab("One-Step Ahead Squared Forecast Error")+theme(text  = element_text(size = 30),
axis.title =     element_text(size = 30),
axis.text.x = element_text(size = 20,))
hrbrmstr
  • 77,368
  • 11
  • 139
  • 205
BaconDoggie
  • 153
  • 3
  • 14
  • I think I can answer my own question but I am not satisfied with my results. I combined from what I saw here http://rpubs.com/kohske/dual_axis_in_ggplot2 with http://rpubs.com/MarkusLoew/13295 to make first one combined plot then aggregating more plots vertically – BaconDoggie May 01 '14 at 06:37
  • 1
    See this possible duplicate http://stackoverflow.com/questions/21981416/dual-y-axis-in-ggplot2-for-multiple-panel-figure where the OP seems to have solved the issue themselves. – MattLBeck May 14 '14 at 08:13
  • I'll assume you have answered your question, however wanted to direct you to another solution http://stackoverflow.com/questions/26917689/how-to-use-facets-with-a-dual-y-axis-ggplot – Dan Nov 17 '14 at 05:55

0 Answers0