[R] (no subject)
Ulrik Stervbo
ulrik.stervbo at gmail.com
Fri Jan 8 18:02:25 CET 2016
Hi Matthias,
Your dat.vline should include the 'variable' as you facet on this.
HTH
On Fri, 8 Jan 2016 at 17:49 Matthias Worni <wornimatthias at gmail.com> wrote:
> Thank you for the help. It worked out fine. However trying to add
> additional aesthetics I came to another point, where I couldnt figure out a
> way to solve it. Perhaps you run into similar problems since your familiar
> with the ggplot package.
>
> The code is the following:
>
> runmean_10yr_Nino_3_Index_17th_century <-
> SMA(SST_NINO3_detrended[0:100],n=10)
> runmean_10yr_Nino_3_Index_18th_century <-
> SMA(SST_NINO3_detrended[101:200],n=10)
> runmean_10yr_Nino_3_Index_19th_century <-
> SMA(SST_NINO3_detrended[201:300],n=10)
> runmean_10yr_Nino_3_Index_20th_century <-
> SMA(SST_NINO3_detrended[301:400],n=10)
>
>
> time_Nino3 <- c(1:100)
> runmean_yearly_decadal_Nino_Index <-
>
> data.frame(runmean_10yr_Nino_3_Index_17th_century,runmean_10yr_Nino_3_Index_18th_century,runmean_10yr_Nino_3_Index_19th_century,runmean_10yr_Nino_3_Index_20th_century,time_Nino3)
> melted3 <- melt(runmean_yearly_decadal_Nino_Index , id.vars="time_Nino3")
>
> ggplot(data=melted3, aes(x=time_Nino3,y=value,colour=variable))+
> geom_line()+ ylab("SST Anomaly") + xlab("year") + ggtitle("Decadal El
> Nino Index ")+ facet_grid(variable ~ .) +
> geom_vline(aes(xintercept = xp),data=dat.vline)
>
> dat.vline <- data.frame( xp = c(15, 23))
>
>
> As you may have noticed I created several plots below each other and now I
> would like to add vertical lines to this plots, therefore adding
> "geom_vline(aes(xintercept = xp),data=dat.vline). This worked so far,
> however I would like to add vertical lines for these four different plots
> at different places. Do you know how I could do this? I added the plot I
> created at this e-mail. You can see two lines on every of those 4 plots (at
> the same place). What I want is the same thing but the lines at different
> places for every of those 4 plots (independently). Thank you for the help!!
> If you need to create the plots you can simply change the
> "runmean_10yr_Nino_3_Index_17th_century" to any other vector.
>
> Best Matthias
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
[[alternative HTML version deleted]]
More information about the R-help
mailing list