| plotFun.ts | R Documentation |
Wrapper function for plotFun.ts.orig, i.e. allow saving and assertion statements.
plotFun.ts(data, dates, hour = FALSE, agg = NULL, aggFun = "mean", season = NULL, export = FALSE, outDir = "current", outNam = "plot1", outDev = "pdf", title = NULL, input.mch = FALSE, window.width = NULL, window.height = NULL, output.data = FALSE, stn.together = FALSE, col.lines = rainbow(10))
data |
Matrix with the data to be plotted (time steps in rows, stations in columns). The column names are used for labels in the plot, otherwise a,b,c,... are used. |
dates |
Vector of dates (POSIX class) of the original data. |
hour |
logical. Is the input data hourly? Hourly data can only use aggregation 'D'. Default: FALSE. |
agg |
Level of temporal aggregation: daily ("D", only for hourly input data), monthly ("M"), seasonal ("S"), annual ("Y"). Default: NULL (all data is plotted using the original temporal resolution). This argument is only valid for |
aggFun |
Function for temporal aggregation, if desired. Possible values: mean, median, min, max. Default: mean. |
season |
Vector with the desired month (season) to be plotted, e.g. 8 is August, c(6,7,8) is JJA, with the operation of 'aggFun'. Default: NULL (no seasonal/monthly slice considered). |
export |
Logical, plot is exported to file (TRUE) or not (FALSE). Default: FALSE. |
outDir |
Directory to export the plot. Default: working directory. |
outNam |
Name of the exported file. Default: climdex.heat |
outDev |
Extension of the exported file. Possible values: pdf, png. Default: pdf. |
title |
character string with the main title. A 1-element vector would set the same title to all subplots, a n-element vector would have the titles for n subplots. |
input.mch |
logical. If the input data is from DWH, the hourly needs to be aggregated differently. See |
window.width |
Width of the plotting window in inches. Default: 7 for map, 14 for time series. |
window.height |
Height of the plotting window in inches. Default: 5 for map, 8.5 for time series. |
output.data |
Logical, return plotted data or not. Default: FALSE. |
stn.together |
Logical, set to TRUE to plot all stations with colour lines in one plot. Default: FALSE. Only available for time series plots. |
col.lines |
Vector with colours for lines. Only available for time series plots. |
Plot time series of one vector. It is possible to plot the "raw" series or aggregate it temporarily or display a specific season/month. If the input data is a matrix, by default a separate panel is obtained for each station. 'stn.together' allows to plot all stations together (without subplot).
A time series plot. Plotted data if 'output.data'=TRUE.
## Not run:
# Generate some data
dates.day <- seq(as.POSIXct(as.Date("20000101", format='%Y%m%d'), tz="UTC"),
as.POSIXct(as.Date("20171231", format='%Y%m%d'), tz="UTC"), by="day")
dates.hour <-seq(as.POSIXlt("201601010000", format='%Y%m%d%H%M'),
as.POSIXlt("201712312350", format='%Y%m%d%H%M'), by="hour")
data.day <- array(runif(length(dates.day)*2, -5, 30), dim=c(length(dates.day),2))
data.hour <- array(runif(length(dates.hour)*2, -5, 30), dim=c(length(dates.hour),2))
# Plot original data
plotFun.ts(data.day, dates.day, title = c("Original daily data"))
plotFun.ts(data.hour, dates.day, title = c("Original hourly data"), hour=T)
# Plot temporarily aggregated data
plotFun.ts(data.day, dates.day, title = "Yearly data", agg="Y")
plotFun.ts(data.day, dates.day, title = "Monthly data", agg="M")
plotFun.ts(data.day, dates.day, title = "Seasonal data", agg="S")
plotFun.ts(data.hour, dates.hour, hour=T, title = "Daily data", agg="D")
# Plot a specific season or month
plotFun.ts(data.day, dates.day, title = "Seasonal data in summer", season = c(6,7,8))
plotFun.ts(data.day, dates.day, title = c("Monthly data in June A", "Monthly data in June B"),
season = 6) # and different subtitles
# Plot all stations together instead of in subplot
plotFun.ts(data.day, dates.day, title = "Monthly data in June A", season = 6, stn.together=T)
# Plot and save plotted data
res <- plotFun.ts(data.day, dates.day, title = "Monthly data in June", season = 6,
output.data = T)
# Export plot to file
plotFun.ts(data.day, dates.day, title = "Monthly data in June", season = 6, export = T)
# Change window size
plotFun.ts(data.day, dates.day, title = "Monthly data in June", season = 6,
window.width = 8, window.height = 4)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.