macroPlot-methods: Plot time series from SOIL or MACRO simulation data (input or...

macroPlotR 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, ...)

## 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.

...

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

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.

Value

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

Examples


library( "macroutils2" )



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

#   Path to the file to be read
( filenm <- system.file( c( 
    "bintest/chat_winCer_GW-D_1kgHa_d298_annual_output.bin", 
    "bintest/chat_pot_GW-D_1kgHa_d119_biennial_output.bin" ), 
    package  = "macroutils2", 
    mustWork = TRUE 
) )

#   Read these 2 files
out1  <- macroReadBin( f = filenm[ 1 ] ) 

out2 <- macroReadBin( f = filenm[ 2 ] ) 

#   Inspect the data:
head( out1 ); dim( out1 ) 
head( out2 ); dim( out2 ) 


#   Shorten the 2nd file to the same length as the 1st
out2 <- out2[ out2[, "Date" ] %in% out1[, "Date" ], ]


# ====== Plot the data ======

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

#   In one plot (not so meaningful in this case!)
macroPlot( x = out1[, 1:4 ], gui = FALSE, subPlots = FALSE ) 

#   Plot Multiple tables at once 
#   Format a list of tables (as when interactively imported)
out1out2        <- list( out1[, 1:4 ], out2[, 1:4 ] ) 
names(out1out2) <- c( "out1", "out2" ) 

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

julienmoeys/macroutils2 documentation built on Feb. 28, 2024, 2:17 a.m.