BarplotUpstreamClasses {HYPEtools} | R Documentation |
Bar plots of upstream-averaged classes of HYPE sub-basins
Description
Function to plot upstream-averaged landscape property classes of one or several sub-basins as bar plots, e.g.
land use or soils. Builds on barplot
.
Usage
BarplotUpstreamClasses(
x,
type = c("custom", "landuse", "soil", "crop"),
desc = NULL,
class.names = NULL,
xlab = NULL,
ylab = "Area fraction (%)",
ylim = c(-0.05, max(x[, -1] * 150)),
names.arg = rep("", ncol(x) - 1),
cex.axis = 1,
cex.names = 0.9,
col = NULL,
border = NA,
legend.text = NULL,
legend.pos = "left",
pars = list(mar = c(1.5, 3, 0.5, 0.5) + 0.1, mgp = c(1.5, 0.3, 0), tcl = NA, xaxs =
"i")
)
Arguments
x |
Data frame, containing column-wise class group fractions with SUBIDs in first column. Typically a result
from |
type |
Character string keyword for class group labeling, used in combination with |
desc |
List for use with |
class.names |
Character vector of class group names, with same length as number of class group fractions in |
xlab |
Character string, x-axis label, with defaults for standard groups land use, soil, and crops. |
ylab |
Character string, y-axis label. |
ylim |
Numeric, two element vector with limits for the y-axis. Defaults to values which give ample space for bar labels. |
names.arg |
Character vector, see |
cex.axis |
Numeric, character expansion factor for axis annotation and labels. |
cex.names |
Numeric, character expansion factor for class group labels. |
col |
Colors for bars. Defaults to |
border |
Colors for bar borders. Defaults to no borders. |
legend.text |
Character, if provided, a legend will be plotted. Defaults to none if one sub-basin is plotted, and SUBIDs
if several sub-basins are plotted. Set to |
legend.pos |
Character keyword for legend positioning, most likely |
pars |
List of tagged values which are passed to |
Details
BarplotUpstreamClasses
is a wrapper for barplot
, with vertical labels plotted over the class group bars.
Most arguments have sensible defaults, but can be adapted for fine-tuning if necessary.
Column names of x
are used to link class groups to class IDs in desc
. HYPE has no formal
requirements on how class IDs are numbered and when one of the standard groups land use, soil, or crop are provided in x
,
there might be missing class IDs. Class names in desc
are matched against column name endings '_x'
in x
.
If manual names are provided in class.names
, the column name endings must be a consecutive sequence from 1 to number of elements
in class.names
.
Value
The function returns bar midpoints, see description in barplot
.
See Also
UpstreamGroupSLCClasses
barplot
Examples
# Import source data
te1 <- ReadGeoData(filename = system.file("demo_model", "GeoData.txt", package = "HYPEtools"))
te2 <- ReadGeoClass(filename = system.file("demo_model", "GeoClass.txt", package = "HYPEtools"))
te3 <- ReadDescription(filename = system.file("demo_model", "description.txt",
package = "HYPEtools"))
# Calculate plot data, upstream soil fractions
te4 <- UpstreamGroupSLCClasses(subid = 63794, gd = te1, gcl = te2, type = "soil")
# Function call
BarplotUpstreamClasses(x = te4, type = "s", desc = te4, ylim = c(0,100))