ggmatrix | R Documentation |
Make a generic matrix of ggplot2 plots.
ggmatrix(
plots,
nrow,
ncol,
xAxisLabels = NULL,
yAxisLabels = NULL,
title = NULL,
xlab = NULL,
ylab = NULL,
byrow = TRUE,
showStrips = NULL,
showAxisPlotLabels = TRUE,
showXAxisPlotLabels = TRUE,
showYAxisPlotLabels = TRUE,
labeller = NULL,
switch = NULL,
xProportions = NULL,
yProportions = NULL,
progress = NULL,
data = NULL,
gg = NULL,
legend = NULL
)
plots |
list of plots to be put into matrix |
nrow , ncol |
number of rows and columns |
xAxisLabels , yAxisLabels |
strip titles for the x and y axis respectively. Set to |
title , xlab , ylab |
title, x label, and y label for the graph. Set to |
byrow |
boolean that determines whether the plots should be ordered by row or by column |
showStrips |
boolean to determine if each plot's strips should be displayed. |
showAxisPlotLabels , showXAxisPlotLabels , showYAxisPlotLabels |
booleans that determine if the plots axis labels are printed on the X (bottom) or Y (left) part of the plot matrix. If |
labeller |
labeller for facets. See |
switch |
switch parameter for facet_grid. See |
xProportions , yProportions |
Value to change how much area is given for each plot. Either |
progress |
|
data |
data set using. This is the data to be used in place of 'ggally_data' if the plot is a string to be evaluated at print time |
gg |
ggplot2 theme objects to be applied to every plot |
legend |
May be the two objects described below or the default
|
Now that the print.ggmatrix
method uses a large gtable object, rather than print each plot independently, memory usage may be of concern. From small tests, memory usage flutters around object.size(data) * 0.3 * length(plots)
. So, for a 80Mb random noise dataset with 100 plots, about 2.4 Gb of memory needed to print. For the 3.46 Mb diamonds dataset with 100 plots, about 100 Mb of memory was needed to print. The benefits of using the ggplot2 format greatly outweigh the price of about 20% increase in memory usage from the prior ad-hoc print method.
Barret Schloerke
# Small function to display plots only if it's interactive
p_ <- GGally::print_if_interactive
plotList <- list()
for (i in 1:6) {
plotList[[i]] <- ggally_text(paste("Plot #", i, sep = ""))
}
pm <- ggmatrix(
plotList,
2, 3,
c("A", "B", "C"),
c("D", "E"),
byrow = TRUE
)
p_(pm)
pm <- ggmatrix(
plotList,
2, 3,
xAxisLabels = c("A", "B", "C"),
yAxisLabels = NULL,
byrow = FALSE,
showXAxisPlotLabels = FALSE
)
p_(pm)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.