Create scatterplots of model performance by SUBID attributes.
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
)
PlotPerformanceByAttribute
returns a plot to the currently active plot device.
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.
Column index of information in subass
to plot on the y-axis of the output plots.
Optional data frame object to specify groups of SUBIDs to plot separately. First column should contain SUBIDs and second column should contain group IDs.
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
Specify how to join subass
to attributes
. Default "join" will perform a dplyr::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).
Specify how to join subass
to groups
. Default "join" will perform a dplyr::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).
Vector containing colors to use when plotting groups. Only used if groups is not NULL
.
Logical, should unused factor levels be omitted from the legend. See ggplot2::scale_color_manual and ggplot2::scale_fill_manual.
Numeric value to set transparency of dots in output plots. Should be in the range 0-1.
Logical, if TRUE
, then trendlines will be added to the output plots. Set to FALSE
to hide trendlines. See ggplot2::geom_smooth.
Specify method used to create trendlines. See ggplot2::geom_smooth.
Specify formula used to create trendlines. See ggplot2::geom_smooth.
Numeric value to set transparency of trendlines in output plots. Should be in the range 0-1.
Numeric value to make the trendlines darker color shades of their corresponding scatterplot points. Should be in the range 1-100.
Logical, if TRUE
, then density plots will be added to the output plots. Set to FALSE
to hide density plots.
String, type of plot geometry to use for density plots: "density"
for ggplot2::geom_density or "boxplot"
for ggplot2::geom_boxplot. Outliers are hidden from the boxplots.
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 ggplot2::scale_x_log10.
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 ggplot2::scale_y_log10.
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 scales::pseudo_log_trans.
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 scales::pseudo_log_trans.
Vector containing minimum and maximum values for the x-axis of the output plots. See ggplot2::scale_x_continuous.
Vector containing minimum and maximum values for the y-axis of the output plots. See ggplot2::scale_y_continuous.
Vector containing the break values used for the x-axis of the output plots. See ggplot2::scale_x_continuous.
Vector containing the break values used for the y-axis of the output plots. See ggplot2::scale_y_continuous.
Vector containing the labels for each break value used for the x-axis of the output plots. See ggplot2::scale_x_continuous.
Vector containing the labels for each break value used for the y-axis of the output plots. See ggplot2::scale_y_continuous.
String containing the text to use for the x-axis title of the output plots. See ggplot2::xlab.
String containing the text to use for the y-axis title of the output plots. See ggplot2::ylab.
Integer, number of columns to use in the output arranged plot. See ggpubr::ggarrange.
Integer, number of rows to use in the output arranged plot. See ggpubr::ggarrange.
Specify how output plots should be arranged. See ggpubr::ggarrange.
Specify if arranged plot should use a common legend. See ggpubr::ggarrange.
Specify position of common legend for arranged plot. See ggpubr::ggarrange. Use "none"
to hide legend.
String, title for plot legend when generating plots with groups
.
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.
Logical, if TRUE
, then a table providing summary statistics will be included at the bottom of the output plot.
Numeric, controls spacing between plots and summary table.
String, filename used to save plot. File extension must be specified. See ggplot2::ggsave.
Numeric, specify width of output plot. See ggplot2::ggsave.
Numeric, specify height of output plot. See ggplot2::ggsave.
Specify units of width
and height
. See ggplot2::ggsave.
Specify resolution of output plot. See ggplot2::ggsave.
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.
ReadSubass
for HYPE result import; SubidAttributeSummary
for subbasin attribute summary
# \donttest{
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)
)
# }
Run the code above in your browser using DataLab