2

I found one relevant question here, but my story is different. Using R OpenAir package, I am trying to create some beautiful timeseries plots (time period: December 2014 - May 2015). Here is the code:

timePlot(data, pollutant=c("NO_predicted", "NO_modelled"), group = TRUE, cols=c("blue", "red"),
         data.thresh = 0, xlab="Year", ylab="Observed and Predicted NO", 
         lty=c(1, 1), lwd=c(1, 1), xlim = as.POSIXct(c("2014-12-01", "2015-05-31")))

This is how the plot looks like:

enter image description here

I want to make it more beautiful by adding years in the x-axis labels. For example, Dec-14, Jan-15, Feb-15 and so on.

Can someone suggest how to that?

zx8754
  • 52,746
  • 12
  • 114
  • 209
khajlk
  • 791
  • 1
  • 12
  • 32

1 Answers1

1

Please read the documentation of timePlot. There are two options that are of interest to you:

date.breaks Number of major x-axis intervals to use. The function will try and choose a sensible number of dates/times as well as formatting the date/time appropriately to the range being considered. This does not always work as desired automatically. The user can therefore increase or decrease the number of intervals by adjusting the value of date.breaks up or down.

date.format This option controls the date format on the x-axis. While timePlot generally sets the date format sensibly there can be some situations where the user wishes to have more control. For format types see strptime. For example, to format the date like “Jan-2012” set date.format = "%b-%Y".

Amar
  • 1,340
  • 1
  • 8
  • 20