This function plots a data frame in ggplot2 format (variables in columns,
observations in rows), likely returned by the functions
multiModelTP
and multiSpeciesTP
. This is
especially useful when there are several species or communities to compare,
and a combined plot is preferred.
credibilityIntervals(
df,
x = "consumer",
plotAlpha = TRUE,
legend = NULL,
legendAlpha = NULL,
y1 = "mode",
y1min = "lower",
y1max = "upper",
y1lim = NULL,
y2 = "alpha.mode",
y2min = "alpha.lower",
y2max = "alpha.upper",
xlab = "Bayesian models",
ylab1 = "Posterior trophic position",
ylab2 = "Posterior alpha",
group_by = NULL,
scale_colour_manual = NULL,
labels = NULL,
plot = TRUE,
...
)
a gtable (if alpha is plotted) with two ggplot2 objects or a ggplot2 object (if alpha is not plotted)
data frame with at least 4 columns, a grouping variable, maximum, minimum and a central tendency descriptor (median, mode, etc.).
string defining the grouping variable.
logical. If TRUE it expects that the data frame has at least 7 columns, another descriptor of central tendency, its maximum and minimum.
list, position of the legend if not NULL, e.g. c(0.8, 0.8).
list, position of the legend for the alpha plot, if not NULL, e.g. c(0.8, 0.8).
string of the column with the central tendency descriptor of trophic position. By default, is the mode.
lower value plotted for trophic position. For the 95 credibility interval, this value would be 0.025 percentile.
higher value plotted for trophic position. For the 95 credibility interval, this value would be 0.975 percentile.
vector of length 2, with limits of the y axis of trophic position.
string of the column with the central tendency descriptor of alpha.
lower value plotted for alpha. For the 95 this value would be percentile 0.025.
higher value plotted for alpha. For the 95 interval, this value would be percentile 0.0975.
string of the label of the X axis.
string of the label of Y1 axis (trophic position).
string of the label of Y2 axis (alpha).
grouping variable (factor) in case of using colours.
a list of colours (ggplot2 syntaxis) to use with group_by.
string, manual labels for the x axis.
logical, by default TRUE. In case of saving the output as a variable, the user can decide not to plot the output.
additional parameters passed to credibilityIntervals().
isotopeData <- generateTPData()
models <- multiModelTP(isotopeData, n.adapt = 200, n.iter = 200,
burnin = 200)
credibilityIntervals(models$gg, x = "model")
Run the code above in your browser using DataLab