ez.barplot | R Documentation |
barplot with ggplot
ez.barplot(
df,
cmd,
color = "color",
colors = ez.palette("Zhu"),
bar.gap = 0.7,
bar.width = 0.7,
error.size = 0.7,
error.gap = 0.7,
error.width = 0.3,
error.direction = "both",
ylimits = NULL,
ybreaks = NULL,
ylab = NULL,
xlab = NULL,
zlab = NULL,
legend.position = "top",
legend.direction = "horizontal",
legend.box = T,
legend.size = c(0, 10),
xangle = 0,
vjust = NULL,
hjust = NULL,
print2scr = TRUE,
point = FALSE,
point.jitter = 0.15,
point.size = 1.5,
point.alpha = 1,
point.color = "grey55",
theme.apa = TRUE,
reorder = FALSE,
reorder.direction = "az",
signif = TRUE,
prefix = -1,
pe = TRUE,
showns = FALSE,
comparisons = NULL,
annotations = NULL,
map_signif_level = FALSE,
y_position = NULL,
xmin = NULL,
xmax = NULL,
margin_top = 0.1,
step_increase = 0.5,
extend_line = 0,
tip_length = 0.15,
size = 0.5,
textsize = 3.88,
family = "",
vjust2 = 0.4,
parse = FALSE,
manual = FALSE,
orientation = NA,
na.rm = TRUE,
...
)
df |
data frame in long format (but be careful that standard error might be inaccurate depending on grouping in the long format)
|
cmd |
like "y|x, y|x z, y|x z a", where y (axis) is continous, x (axis) z/a (legend) are discrete; during plot x z a ->x za(combined)
|
color |
"bw" or "color" black/white or colorblind-friendly color |
bar.gap |
the gap between bars |
bar.width |
the width of bar itself |
error.size |
the thickness of error bar (vertical and horizontal lines) |
error.gap |
the location of errorbar, should be equal to bar.width(?) |
error.width |
the width of error bar (horizontal lines), could be 0 to show only vertical lines |
error.direction |
"both", "max", "min" |
ylimits |
or ylim, e.g.,c(0,0.5). ylimits does not require ybreaks set |
ybreaks |
e.g.,seq(0,0.5,by=0.1). ybreaks requires ylimits set |
ylab |
y label NULL |
xlab |
x label NULL |
zlab |
z/a/fill/legend label, only applicable when there is z provided NULL |
legend.position |
legend position 'top', 'bottom', 'left', 'right', 'none', c(x,y,two-element numeric vector)
|
legend.direction |
horizontal or vertical |
legend.box |
box of legend, T or F |
legend.size |
c(0,10) the first number 0 controls the legend title, 0=hide; the second number controls legend.key.size, legend.text |
xangle |
angle of x text 0 |
vjust |
vjust of x text NULL |
hjust |
hjust of x text NULL |
reorder |
T/F whether to reorder x by the group means (raw means if no covar, adjusted means if covar) |
reorder.direction |
'az' or 'za' |
signif |
add signif to the plot (only works for anovas1b with/without covar) |
prefix |
-1 (****,***,**,*,ns); 0 (< .0001, < .001, .003, .2); 1 (< .0001, < .001, = .003, = .02); 2 (p < .0001, < .001, p = .003, p = .02) |
pe |
affects only p < .0001 or < .001. if T, would be sth like 3.14e-04; otherwise < .0001 or < .001 |
showns |
if T, show ns or .2; F, only display significant ones |
comparisons |
A list of length-2 vectors. The entries in the vector are either the names of 2 values on the x-axis or the 2 integers that correspond to the index of the columns of interest. if NULL, permute all combinations. e.g., comparisons = list(c("compact", "pickup"), c("subcompact", "suv")) |
annotations |
character vector with alternative annotations. if NULL, auto compute annotations = c("First", "Second"), formatC(0.92, digits=1) |
map_signif_level |
NOT WORKING (because I manually pass in annotations?)–Use prefix=-1, Boolean value, if the p-value are directly written as annotation or asterisks are used instead. Alternatively one can provide a named numeric vector to create custom mappings from p-values to annotation: For example: 'c("***"=0.001, "**"=0.01, "*"=0.05)'. Alternatively, one can provide a function that takes a numeric argument (the p-value) and returns a string. map_signif_level = function(p) sprintf("p = %.2g", p) |
y_position |
numeric vector with the y positions of the brackets |
xmin , xmax |
numeric vector with the positions of the left and right sides of the brackets, respectively |
margin_top |
controls distance between the bar and the line. numeric vector how much higher that the maximum value that bars start as fraction of total height |
step_increase |
numeric vector with the increase in fraction of total height for every additional comparison to minimize overlap. |
extend_line |
Numeric that allows to shorten (negative values) or extend (positive value) the horizontal line between groups for each comparison; defaults to 0. bar goes down to indicate the precise column |
tip_length |
numeric vector with the fraction of total height that the |
size |
change the thickness of the lines of the bracket |
textsize |
change the size of the text |
family |
change the font used for the text |
vjust2 |
move the text up or down relative to the bracket (+down,-up) |
parse |
If 'TRUE', the labels will be parsed into expressions and displayed as described in '?plotmath'. |
manual |
Boolean flag that indicates that the parameters are provided with a data.frame. This option is necessary if one wants to plot different annotations per facet. |
orientation |
The orientation of the layer. The default ('NA') automatically determines the orientation from the aesthetic mapping. In the rare event that this fails it can be given explicitly by setting 'orientation' to either "x" or "y" |
na.rm |
If 'FALSE', removes missing values with a warning. If 'TRUE' silently removes missing values. |
... |
additional params to |
a ggplot object (+theme_apa() to get apa format plot), +scale_y_continuous(limits=c(-5,8),breaks=seq(-5,8,by=2),oob=scales::rescale_none)
see http://stackoverflow.com/a/31437048/2292993 for discussion
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.