1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
|
#' Facet specification.
#'
#' Create new facetting specification. For internal use only.
#'
#' @param ... object fields
#' @param shrink shrink scales to fit output of statistics, not raw data
#' @keywords internal
#' @export
facet <- function(..., shrink = TRUE, subclass = c()) {
structure(list(..., shrink = shrink), class = c(subclass, "facet"))
}
#' Is this object a facetting specification?
#'
#' @param x object to test
#' @keywords internal
#' @export
is.facet <- function(x) inherits(x, "facet")
# Figure out layout from data from plot and all layers.
#
# This creates the layout data frame which maps from data values to
# panel coordinates: ROW, COL and PANEL. It also records the panels that
# contribute to each x and y scale.
#
# @param data a list of data frames (one for the plot and one for each
# layer)
facet_train_layout <- function(facet, data)
UseMethod("facet_train_layout")
facet_map_layout <- function(facet, data, layout)
UseMethod("facet_map_layout")
facet_render <- function(facet, panels_grob, coord, theme, geom_grobs)
UseMethod("facet_render")
facet_strips <- function(facet, panel, theme)
UseMethod("facet_strips")
facet_panels <- function(facet, panel, coord, theme, geom_grobs)
UseMethod("facet_panels")
facet_axes <- function(facet, panel, coord, theme)
UseMethod("facet_axes")
# Text description of facetting variables
facet_vars <- function(facet)
UseMethod("facet_vars")
#' @export
format.facet <- function(x, ...) {
name <- paste(rev(class(x)), collapse = "_")
paste(name, "(", facet_vars(x), ")", sep = "")
}
#' @export
print.facet <- function(x, ...) {
cat(format(x, ...), "\n")
}
|