multiple time series plots

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

multiple time series plots

pari hesabi
Dear Friends,

I am trying to add two time series curves into one plot. I don't get any error but the lines are not added to my plot.
I am trying the following code;

1) df <- as.data.frame (read_excel("C:/Users/NO2.xlsx", "trend))

2) plot(df$year, df$Nation, type="o", col="blue", lty=1, ylab="change" )

3) lines(df$year, df$East, col="red",lty=2)

4) lines(df$year, df$center, col="dark red", lty=3)

I need to mention that Nation, East and Center are some probability values.
And year, is a sequence of years. Lines 1 and 2 are run properly but lines 3 and 4 are not added.

I would appreciate any idea.

Regards,

Peri

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: multiple time series plots

Jim Lemon-4
Hi Peri,
Without the data this is only a guess, but are the values of East and
center within the limits of the plot generated by Nation?

Jim

On Fri, Sep 18, 2020 at 10:12 AM peri He <[hidden email]> wrote:

>
> Dear Friends,
>
> I am trying to add two time series curves into one plot. I don't get any error but the lines are not added to my plot.
> I am trying the following code;
>
> 1) df <- as.data.frame (read_excel("C:/Users/NO2.xlsx", "trend))
>
> 2) plot(df$year, df$Nation, type="o", col="blue", lty=1, ylab="change" )
>
> 3) lines(df$year, df$East, col="red",lty=2)
>
> 4) lines(df$year, df$center, col="dark red", lty=3)
>
> I need to mention that Nation, East and Center are some probability values.
> And year, is a sequence of years. Lines 1 and 2 are run properly but lines 3 and 4 are not added.
>
> I would appreciate any idea.
>
> Regards,
>
> Peri
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] 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.

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: multiple time series plots

Jim Lemon-4
Hi Peri,
In that case, try this:

ylim<-range(c(df$Nation,df$East,df$Center),na.rm=TRUE)
plot(df$year, df$Nation, type="o", col="blue", lty=1, ylab="change",ylim=ylim)

Jim

On Fri, Sep 18, 2020 at 11:10 AM peri He <[hidden email]> wrote:

>
> Hi Jim,
>
> Thank you for your reply.
>
> Sorry I am messaging you instead of asking publicly.
> Actually Nation, center and East are like medium and confidence intervals.
> So no, they are not in the limit of each other.
> I am trying to find a way to plot them in one chart. Most of the codes give me error.
>
> ________________________________
> From: Jim Lemon <[hidden email]>
> Sent: Friday, September 18, 2020 12:21 AM
> To: peri He <[hidden email]>
> Cc: [hidden email] <[hidden email]>
> Subject: Re: [R] multiple time series plots
>
> Hi Peri,
> Without the data this is only a guess, but are the values of East and
> center within the limits of the plot generated by Nation?
>
> Jim
>
> On Fri, Sep 18, 2020 at 10:12 AM peri He <[hidden email]> wrote:
> >
> > Dear Friends,
> >
> > I am trying to add two time series curves into one plot. I don't get any error but the lines are not added to my plot.
> > I am trying the following code;
> >
> > 1) df <- as.data.frame (read_excel("C:/Users/NO2.xlsx", "trend))
> >
> > 2) plot(df$year, df$Nation, type="o", col="blue", lty=1, ylab="change" )
> >
> > 3) lines(df$year, df$East, col="red",lty=2)
> >
> > 4) lines(df$year, df$center, col="dark red", lty=3)
> >
> > I need to mention that Nation, East and Center are some probability values.
> > And year, is a sequence of years. Lines 1 and 2 are run properly but lines 3 and 4 are not added.
> >
> > I would appreciate any idea.
> >
> > Regards,
> >
> > Peri
> >
> >         [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > [hidden email] 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.

______________________________________________
[hidden email] 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.