r - Time-series plot for different seasons in the same plot -


i plot time series data different seasons of year (grouped cold or warm) in same plot , identify 2 periods. how can that?

reproducible data follows:

library(gamair)  data(chicago)  chicago$date<-seq(from=as.date("1987-01-01"), to=as.date("2000-12-31"),length=5114) data.cold <- subset(chicago, quarters(date) %in% c("q1", "q4")) data.warm <- subset(chicago, quarters(date) %in% c("q2", "q3")) 

these codes below create 2 separate plots 2 periods:

with(data.cold,plot(date,death,pch=".", ylab= expression("mortality count"), main = "daily mortality in cold season")) with(data.warm ,plot(date,death,pch=".", ylab= expression("mortality count"), main = "daily mortality in warm season")) 

this following code creates 1 plot, there no clear demarcation of 2 periods. wish create identifiable plot 2 periods in single plot.

with(chicago,plot(date,death,pch=".", ylab= expression("mortality count"), main = "daily mortality  1987-2000")) 

have @ ?points:

with(data.cold,plot(date,death,pch=".", ylab= expression("mortality count"), main = "daily mortality in cold season")) with(data.warm ,points(date,death,pch=".", ylab= expression("mortality count"), main = "daily mortality in warm season", col="red")) legend("topright", c("cold", "warm"), fill=c("black", "red")) 

does work you?


Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -