METplus Practical Session Guide (Version 5.0) | MET Tool: TC-Stat > Plotting with R

TC-Stat: Plotting with R

In this section, you will use the R statistics software package to produce a plot of a few results. R was introduced in practical session 1.

The MET release includes a number of plotting tools for TC graphics. All of the Rscripts are included with the MET distribution in the Rscripts directory. The script for TC graphics is plot_tcmpr.R, which uses the TCST output files from TC-Pairs as input. At this time, there are two additional environment variables that need to be set to make this work.  They are MET_INSTALL_DIR and MET_BASE. To get the usage statement, type:

For Bash:

export MET_INSTALL_DIR=${MET_BUILD_BASE}
export MET_BASE=${MET_INSTALL_DIR}/share/met
Rscript ${MET_BASE}/Rscripts/plot_tcmpr.R

For C-shell:

setenv MET_INSTALL_DIR ${MET_BUILD_BASE}
setenv MET_BASE ${MET_INSTALL_DIR}/share/met
Rscript ${MET_BASE}/Rscripts/plot_tcmpr.R

The TC-Stat tool can be called from the Rscript to do additional filter jobs on the TCST output from TC-Pairs. This can be done on the command line by calling a filter job (following tc-stat), or a configuraton file can be used to select filtering criteria. A default configuration file can be found in Rscripts/include/plot_tcmpr_config_default.R.

The configuration file also includes various plot types to generate: MEAN, MEDIAN, SCATTER, REFPERF, BOXPLOT, and RANK. All of the plot commands can be called on the command line as well as with the configuration file. Plots are configurable (title, colors, axis labels, etc) either by modifying the configuration file or setting options on the command line. To run from the command line:

Rscript ${MET_BASE}/Rscripts/plot_tcmpr.R \
-lookin ../tc_pairs/tc_pairs.tcst \
-filter "-amodel HWRF,CONS" \
-dep "TK_ERR" \
-series AMODEL HWRF,CONS \
-plot MEAN,BOXPLOT,RANK \
-outdir .

This plots the track error for two models: HWRF and CONS. CONS is the user defined consensus you generated in TC-Pairs.

Next, open up the output *png files:

display TK_ERR_boxplot.png &
display TK_ERR_mean.png &
display TK_ERR_rank.png &

The script produces the three plot types called in the configuration file:

  1. Boxplot showing distribution of errors for a homogeneous sample of the two models (TK_ERR_boxplot.png).
  2. Mean Errors with 95% CI for the same sample (TK_ERR_mean.png).
  3. Rank plot indicating performance of HWRF model relative to CONS (TK_ERR_rank.png).