PlotPerformanceByAttribute {HYPEtools}R Documentation

Plot model performance by SUBID attributes

Description

Create scatterplots of model performance by SUBID attributes.

Usage

PlotPerformanceByAttribute(
  subass,
  subass.column = 2,
  groups = NULL,
  attributes,
  join.type = c("join", "cbind"),
  group.join.type = c("join", "cbind"),
  groups.color.pal = NULL,
  drop = TRUE,
  alpha = 0.4,
  trendline = TRUE,
  trendline.method = "lm",
  trendline.formula = NULL,
  trendline.alpha = 0.5,
  trendline.darken = 15,
  density.plot = FALSE,
  density.plot.type = c("density", "boxplot"),
  scale.x.log = FALSE,
  scale.y.log = FALSE,
  xsigma = 1,
  ysigma = 1,
  xlimits = c(NA, NA),
  ylimits = c(NA, NA),
  xbreaks = waiver(),
  ybreaks = waiver(),
  xlabels = waiver(),
  ylabels = waiver(),
  xlab = NULL,
  ylab = NULL,
  ncol = NULL,
  nrow = NULL,
  align = "hv",
  common.legend = TRUE,
  legend.position = "bottom",
  group.legend.title = "Group",
  common.y.axis = FALSE,
  summary.table = FALSE,
  table.margin = 0.4,
  filename = NULL,
  width = NA,
  height = NA,
  units = c("in", "cm", "mm", "px"),
  dpi = 300
)

PlotJohan(
  subass,
  subass.column = 2,
  groups = NULL,
  attributes,
  join.type = c("join", "cbind"),
  group.join.type = c("join", "cbind"),
  groups.color.pal = NULL,
  drop = TRUE,
  alpha = 0.4,
  trendline = TRUE,
  trendline.method = "lm",
  trendline.formula = NULL,
  trendline.alpha = 0.5,
  trendline.darken = 15,
  density.plot = FALSE,
  density.plot.type = c("density", "boxplot"),
  scale.x.log = FALSE,
  scale.y.log = FALSE,
  xsigma = 1,
  ysigma = 1,
  xlimits = c(NA, NA),
  ylimits = c(NA, NA),
  xbreaks = waiver(),
  ybreaks = waiver(),
  xlabels = waiver(),
  ylabels = waiver(),
  xlab = NULL,
  ylab = NULL,
  ncol = NULL,
  nrow = NULL,
  align = "hv",
  common.legend = TRUE,
  legend.position = "bottom",
  group.legend.title = "Group",
  common.y.axis = FALSE,
  summary.table = FALSE,
  table.margin = 0.4,
  filename = NULL,
  width = NA,
  height = NA,
  units = c("in", "cm", "mm", "px"),
  dpi = 300
)

Arguments

subass

Information to plot, typically model performances from imported HYPE 'subassX.txt' files. Data frame object with first column containing SUBIDs and additional columns containing model results to plot. See details.

subass.column

Column index of information in subass to plot on the y-axis of the output plots.

groups

Optional data frame object to specify groups of SUBIDs to plot separately. First column should contain SUBIDs and second column should contain group IDs.

attributes

Data frame object containing the subbasin attribute information to plot on the x-axis of the output plots. Typically a data frame created by SubidAttributeSummary

join.type

Specify how to join subass to attributes. Default "join" will perform a left_join in which the order of the SUBIDs does not need to match. Additional option "cbind" will perform a cbind in which the order of the SUBIDs needs to match; this can be helpful if you want to create plots where subass performance data is calculated according to a grouping variable (e.g. month).

group.join.type

Specify how to join subass to groups. Default "join" will perform a left_join in which the order of the SUBIDs does not need to match. Additional option "cbind" will perform a cbind in which the order of the SUBIDs needs to match; this can be helpful if you want to create plots where subass performance data is calculated according to a grouping variable (e.g. month).

groups.color.pal

Vector containing colors to use when plotting groups. Only used if groups is not NULL.

drop

Logical, should unused factor levels be omitted from the legend. See scale_color_manual and link{scale_fill_manual}.

alpha

Numeric value to set transparency of dots in output plots. Should be in the range 0-1.

trendline

Logical, if TRUE, then trendlines will be added to the output plots. Set to FALSE to hide trendlines. See geom_smooth.

trendline.method

Specify method used to create trendlines. See geom_smooth.

trendline.formula

Specify formula used to create trendlines. See geom_smooth.

trendline.alpha

Numeric value to set transparency of trendlines in output plots. Should be in the range 0-1.

trendline.darken

Numeric value to make the trendlines darker color shades of their corresponding scatterplot points. Should be in the range 1-100.

density.plot

Logical, if TRUE, then density plots will be added to the output plots. Set to FALSE to hide density plots.

density.plot.type

String, type of plot geometry to use for density plots: "density" for geom_density or "boxplot" for geom_boxplot. Outliers are hidden from the boxplots.

scale.x.log

Vector describing if output plots should use a log scale on the x-axis. A pseudo-log scale will be used if any zero or negative values are present. If length of vector == 1, then the value will be used for all output plots. Vector values should be either TRUE or FALSE. See scale_x_log10.

scale.y.log

Vector describing if output plots should use a log scale on the y-axis. A pseudo-log scale will be used if any zero or negative values are present. If length of vector == 1, then the value will be used for all output plots. Vector values should be either TRUE or FALSE. See scale_y_log10.

xsigma

Numeric, scaling factor for the linear part of psuedo-long transformation of x axis. Used if scale.x.log is TRUE and zero or negative values are present. See pseudo_log_trans.

ysigma

Numeric, scaling factor for the linear part of psuedo-long transformation of y axis. Used if scale.y.log is TRUE and zero or negative values are present. See pseudo_log_trans.

xlimits

Vector containing minimum and maximum values for the x-axis of the output plots. See scale_x_continuous.

ylimits

Vector containing minimum and maximum values for the y-axis of the output plots. See scale_y_continuous.

xbreaks

Vector containing the break values used for the x-axis of the output plots. See scale_x_continuous.

ybreaks

Vector containing the break values used for the y-axis of the output plots. See scale_y_continuous.

xlabels

Vector containing the labels for each break value used for the x-axis of the output plots. See scale_x_continuous.

ylabels

Vector containing the labels for each break value used for the y-axis of the output plots. See scale_y_continuous.

xlab

String containing the text to use for the x-axis title of the output plots. See xlab.

ylab

String containing the text to use for the y-axis title of the output plots. See ylab.

ncol

Integer, number of columns to use in the output arranged plot. See ggarrange.

nrow

Integer, number of rows to use in the output arranged plot. See ggarrange.

align

Specify how output plots should be arranged. See ggarrange.

common.legend

Specify if arranged plot should use a common legend. See ggarrange.

legend.position

Specify position of common legend for arranged plot. See ggarrange. Use "none" to hide legend.

group.legend.title

String, title for plot legend when generating plots with groups.

common.y.axis

Logical, if TRUE, then only one y-axis label and marginal density plot will be provided. If FALSE, then separate y-axis labels and marginal density plots will be included for each subplot.

summary.table

Logical, if TRUE, then a table providing summary statistics will be included at the bottom of the output plot.

table.margin

Numeric, controls spacing between plots and summary table.

filename

String, filename used to save plot. File extension must be specified. See ggsave.

width

Numeric, specify width of output plot. See ggsave.

height

Numeric, specify height of output plot. See ggsave.

units

Specify units of width and height. See ggsave.

dpi

Specify resolution of output plot. See ggsave.

Details

PlotPerformanceByAttribute can be used to analyze model performance according to subbasin attributes. The function requires two primary inputs; Model performance information is contained in the subass input, and subbasin attribute information is contained in the attributes input. The subass.column argument controls which column of the subass data frame will be used as the y-coordinate of points. Plots will be generated for each column in the attributes data frame (except for the column named "SUBID") using the column values as the x-coordinate of the points.

A subbasin attribute summary table can be generated using SubidAttributeSummary, and additional columns can be joined to the data frame to add additional output plots.

Value

PlotPerformanceByAttribute returns a plot to the currently active plot device.

See Also

ReadSubass for HYPE result import; SubidAttributeSummary for subbasin attribute summary

Examples


subass <- ReadSubass(filename = system.file("demo_model", "results",
  "subass1.txt",
  package = "HYPEtools"
), check.names = TRUE)
gd <- ReadGeoData(filename = system.file("demo_model",
  "GeoData.txt",
  package = "HYPEtools"
))
gc <- ReadGeoClass(filename = system.file("demo_model",
  "GeoClass.txt",
  package = "HYPEtools"
))

attributes <- SubidAttributeSummary(subids <- subass$SUBID,
  gd = gd, gc = gc,
  mapoutputs = c(system.file("demo_model", "results", "mapCOUT.txt", package = "HYPEtools")),
  upstream.gd.cols = c("SLOPE_MEAN")
)

PlotPerformanceByAttribute(
  subass = subass,
  attributes = attributes[, c("SUBID", "landuse_1", "landuse_2", "landuse_3")],
  xlimits = c(0, 1)
)



[Package HYPEtools version 1.6.2 Index]