1

I have a dataframe with precipitation datewise.

head(df,n=5)
       Date        RCM
1 2018-01-01   31.38134
2 2018-01-02  273.23595
3 2018-01-03 1021.34547
4 2018-01-04  612.70087
5 2018-01-05   37.61821

my aim is to create timeseries for the winter season. I acheived so by extracting winter months from df and used ggplot.

    WIN1<-df[df$Date >= "2018-12-01" & df$Date <= "2018-12-31", ]    
    WIN2<-df[df$Date >= "2018-01-01" & df$Date <= "2018-02-28", ]    
    WIN<-rbind(WIN2,WIN1)
dfmelt<-melt(WIN,id.vars="Date")
ggplot(dfmelt,aes(x=Date,y=value,
                  col=variable))+
  labs(title='WINTER')+
  geom_line()

but this gives the plot with a flatine for the missing months. any way to transform this without the middle part to get a better looking plot. plot

PS: any way of just plotting reverse x axes. so it dec to feb?

hat6ytrs
  • 11
  • 3
  • Does [this](https://stackoverflow.com/questions/14136703/ggplot2-time-series-plotting-how-to-omit-periods-when-there-is-no-data-points) solve your question? – Ric Oct 25 '22 at 20:16
  • Does this answer your question? [ggplot2 time series plotting: how to omit periods when there is no data points?](https://stackoverflow.com/questions/14136703/ggplot2-time-series-plotting-how-to-omit-periods-when-there-is-no-data-points) – Ric Oct 25 '22 at 20:18
  • Not really. This is the final code I'm trying to run after many variations. – hat6ytrs Oct 26 '22 at 16:31
  • trying few variations but its not working. any way of simply plotting it with x axis having Dec to Feb. so reverse and no other months? – hat6ytrs Oct 26 '22 at 21:38
  • to reverse datetime axis you need some hack. [here](https://stackoverflow.com/a/43626186/6912817) is a post . Note it uses functions of `scales` package so import it or modify the code e.g. as.trans should be scales::as.trans. Also change scale_x_continuous for scale_y_continuous – Ric Oct 26 '22 at 22:10

0 Answers0