A wrapper to create box and whiskers plot with some defaults useful for comparing distributions.
chart.Boxplot(
R,
names = TRUE,
as.Tufte = FALSE,
plot.engine = "default",
sort.by = c(NULL, "mean", "median", "variance"),
colorset = "black",
symbol.color = "red",
mean.symbol = 1,
median.symbol = "|",
outlier.symbol = 1,
show.data = NULL,
add.mean = TRUE,
sort.ascending = FALSE,
xlab = "Return",
main = "Return Distribution Comparison",
element.color = "darkgray",
...
)
an xts, vector, matrix, data frame, timeSeries or zoo object of asset returns
logical. if TRUE, show the names of each series
logical. default FALSE. if TRUE use method derived for Tufte for limiting chartjunk
choose the plot engine you wish to use: ggplot2, plotly, googlevis and default
one of "NULL", "mean", "median", "variance"
color palette to use, set by default to rational choices
draws the symbols described in
mean.symbol
,median.symbol
,outlier.symbol
in the color
specified
symbol to use for the mean of the distribution
symbol to use for the median of the distribution
symbol to use for the outliers of the distribution
numerical vector of column numbers to display on top of boxplot, default NULL
logical. if TRUE, show a line for the mean of all distributions plotted
logical. If TRUE sort the distributions by ascending
sort.by
set the x-axis label, same as in plot
set the chart title, same as in plot
specify the color of chart elements. Default is "darkgray"
any other passthru parameters
box plot of returns
We have also provided controls for all the symbols and lines in the chart.
One default, set by as.Tufte=TRUE
, will strip chartjunk and draw a
Boxplot per recommendations by Edward Tufte. It can also be useful when
comparing several series to sort them in order of ascending or descending
"mean", "median", "variance" by use of sort.by
and
sort.ascending=TRUE
.
Tufte, Edward R. The Visual Display of Quantitative Information. Graphics Press. 1983. p. 124-129
# NOT RUN {
data(edhec)
chart.Boxplot(edhec)
chart.Boxplot(edhec,as.Tufte=TRUE)
# }
Run the code above in your browser using DataLab