View source: R/np_plotting_functions.R
drawBoxPlot | R Documentation |
takes a date frame with columns labeled 'at', 'q1', 'q3', 'min', 'max', 'median' and 'width' to draw a series of boxplots.
drawBoxPlot(
x,
col = "black",
fill = NULL,
drawBox = T,
drawDot = F,
whiskerLty = 2,
side = FALSE,
lWidth = 1,
capWidth = 0.25,
capType = "bar"
)
x |
named list or data frame; |
col |
character; color vector that controls the line color. |
fill |
character; color vector that determines the interior color of the box. |
drawBox |
logical; draws the box and whiskers if set to |
drawDot |
logical; draws a circle at the center of the median bar if set to |
whiskerLty |
positive integer; sets the line type or |
side |
logical; if set to |
lWidth |
positive integer; corresponds to lwd line width setting in base R. |
capWidth |
numeric; size of the error bar cap relative to the box width. |
capType |
character; should be equal to |
The input data frame x
should include columns labels named 'at','q1',and 'q3', 'median', 'min', 'max' and 'width' in any order.
Each row will draw a box and whisker plot. The columns 'q1' and 'q3' refer to the 25% and 75% cumulative distribution values that bound the interquartile range.
If side=TRUE
then the x and y axises are swapped to support horizontal plotting. The box and whiskers can be suppressed leaving only the median line and the optional center marker if so desired.
boxplot
, niceBox
data(iris)
library(dplyr)
iData<-iris %>% group_by(Species) %>%
summarize(median=median(Sepal.Length),min=min(Sepal.Length),max=max(Sepal.Length),
q1=quantile(Sepal.Length)[2],q3=quantile(Sepal.Length)[4]) %>%
bind_cols(at=c(1:3),width=c(.2,.3,.4))
plot(1,1,type="n",xlim=c(0,4),ylim=c(0,9))
#\donttest{drawBoxPlot(iData)}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.