macroPlot {macroutils}R Documentation

Plot time series from SOIL or MACRO simulation data (input or output).

Description

Plot time series from SOIL or MACRO simulation data (input or output). When x is missing and/or gui is FALSE, the function pops-up menu asking the user which file(s) and which variable(s) to plot, and how.

Usage

macroPlot(x, ...)

macroPlotBin(x, ...)

## S3 method for class 'macroTimeSeries'
macroPlot(x, ...)

## S3 method for class 'macroTimeSeriesList'
macroPlot(x, ...)

## S3 method for class 'data.frame'
macroPlot(x, ...)

## Default S3 method:
macroPlot(x, gui = TRUE, z = NULL, subPlots = TRUE,
  verbose = TRUE, xlab = "Date", ylab = NULL, ylim = NULL,
  xlim = NULL, col = NULL, sub = NULL, lwd = 2L, lty = NULL,
  main = NULL, cex.main = NULL, panel.first = .paf(), dLegend = TRUE,
  las = 1L, bty = "n", ...)

Arguments

x

A single data.frame, or a list of data.frame containing the data to be plotted. Each data.frame must have at least two columns: one column Date containing dates in POSIXct format (see DateTimeClasses), and one or more named columns of data in some numerical formats. Such data.frame will presumably be imported from bin files, with macroReadBin. If missing, a pop-up menu will ask you the binary files to be read and that contains the variables to be plotted.

gui

Single logical. Set to TRUE if you want to choose only some of the columns in the table passed to x. Will be ignored if interactive is FALSE (i.e. if ran outside R GUI for Windows).

z

Vector of character strings. Name of the variables to include in the graph. If NULL, all variables in 'x' are included, and if gui is TRUE, the user is asked with variable should be included.

subPlots

Single logical. If TRUE (default), all the variables in x will be plotted in separated sub-plots, with sub-plots on top of each others. If FALSE, all the variables in x will be plotted in the same plot, on top of each other, with the same Y axis. If gui is TRUE, subPlots is ignored, and a menu will ask you what to do.

verbose

Single logical. If TRUE, some text message will be displayed on the console to explain what is going on.

xlab

See plot.default. A single character string. Label of the 'x' axis.

ylab

See plot.default. A vector of character strings of length one or of the same length as the variables in (or chosen from) x.

ylim

See plot.default.

xlim

See plot.default.

col

See plot.default or lines. Vector of character strings, line colors.

sub

See plot or title. Vector of character strings, sub-titles of each plot.

lwd

See plot.default or lines. Vector of integers, line widths (thicknesses).

lty

See plot.default. a vector of line types.

main

See plot.default. Plot title(s).

cex.main

See par. Title(s) expansion factor.

panel.first

See plot.default.

dLegend

Single logical value. If TRUE and subPlots=FALSE and more than one variable is plotted, a legend is drawn above the plot (with distinct colors for each variables).

las

See par.

bty

See par.

...

Additional arguments passed to plot and to lines (when subPlots is FALSE). See also plot.default.

Value

Invisibly returns 'x', or the content of the files selected.

Examples

require( "macroutils" )



# ====== Example 1: SOIL model input file ======

#   Path to the file to be read
( filenm <- system.file( 
    c( "bintest/METFILE.BIN", "bintest/RAINFALL.BIN" ), 
    package  = "macroutils", 
    mustWork = TRUE 
) )
## [1] "C:/Users/julienm/Documents/R/win-library/3.2/macroutils/bintest/METFILE.BIN" 
## [2] "C:/Users/julienm/Documents/R/win-library/3.2/macroutils/bintest/RAINFALL.BIN"
#   Read these 2 files
met  <- macroReadBin( file = filenm[ 1 ] ) 

rain <- macroReadBin( file = filenm[ 2 ] ) 

#   Inspect the data:
head( met ); dim( met ) 
##                  Date Max_air_temperature_oC_Sutton_Bonington
## 1 1987-01-01 12:00:00                                     9.2
## 2 1987-01-02 12:00:00                                     6.1
## 3 1987-01-03 12:00:00                                     6.1
## 4 1987-01-04 12:00:00                                    10.5
## 5 1987-01-05 12:00:00                                     7.2
## 6 1987-01-06 12:00:00                                     4.9
##   Min_air_temperature_oC_Sutton_Bonington
## 1                                     5.1
## 2                                     4.5
## 3                                    -2.8
## 4                                    -2.7
## 5                                     4.1
## 6                                     2.7
##   Solar_radiation_W_m_2_Sutton_Bonington_TRS1
## 1                                     6.94446
## 2                                    10.41669
## 3                                    43.98158
## 4                                    11.57410
## 5                                    35.87971
## 6                                    40.50935
##   Vapour_pressure_kPa_Sutton_Bonington_TRS1
## 1                                 0.8800001
## 2                                 0.8200001
## 3                                 0.5000000
## 4                                 0.8100001
## 5                                 0.6900001
## 6                                 0.5100001
##   Wind_speed_m_s_1_Sutton_Bonington_TRS1
## 1                                3.29216
## 2                                2.72632
## 3                                4.16664
## 4                                2.98352
## 5                                4.52672
## 6                                2.67488
## [1] 731   6
head( rain ); dim( rain ) 
##                  Date rainfall
## 1 1987-01-01 12:00:00      2.6
## 2 1987-01-02 12:00:00      0.1
## 3 1987-01-03 12:00:00      0.1
## 4 1987-01-04 12:00:00      1.5
## 5 1987-01-05 12:00:00      3.2
## 6 1987-01-06 12:00:00      0.0
## [1] 731   2
# ====== Plot the data ======

#   With sub-plots
macroPlot( x = met[, 1:4 ], gui = FALSE ) 

#   In one plot
macroPlot( x = met[, 1:4 ], gui = FALSE, subPlots = FALSE ) 

plot of chunk unnamed-chunk-1 plot of chunk unnamed-chunk-1

#   Plot Multiple tables at once 
#   Format a list of tables (as when interactively imported)
metRain        <- list( met, rain ) 
names(metRain) <- c( "METFILE", "RAINFALL" ) 

macroPlot( x = metRain, gui = FALSE, subPlots = TRUE ) 

plot of chunk unnamed-chunk-1


[Package macroutils version 1.8.2 Index]