plot_stats | R Documentation |
Adds text labels on top of bars or boxes of a ggplot2
-based plot.
Useful for annotating statistical analysis information.
plot_stats(plot, d, labels, position = "identity", size = 1, y.adj = 0)
plot |
Plot onto which to add labels. Requires a discrete x scale, optionally dodged by "fill" aesthetic. |
d |
|
labels |
Character. The name of the column with the labels to be plotted. |
position |
Character, either "identity" or "dodge". Sets where (horizontally) the labels should be plotted. Defaults to "identity". If plot is dodged, "dodge" plots labels above each bar or box. "identity" plots them above the middle of each group of bars or boxes. If plot is not dodged, position is automatically set to "identity". |
size |
Numeric. Sets the size of labels. Defaults to 1. |
y.adj |
Numeric. Adjusts the height of labels above each bar, box or group. Defaults to 0. Positive sets it higher, negative sets it lower. |
plot_stats
detects the maximum plotted value of each data group (bar, box, error bar or individual data point),
and plots given labels above it.
The supplied plot needs to be based on ggplot2
and to have a discrete x scale. The supplied data.frame
needs to have a
character
field with the labels to be plotted (whose name is specified in the labels
argument) and factor
field(s)
for the groups in which each label belongs.
A plot based on ggplot2
.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.