combineLimits {latticeExtra}R Documentation

Combine axis limits across margins


Modifies a "trellis" object with "free" scales so that panel limits are extended to be the same across selected conditioning variables (typically rows and columns).


combineLimits(x, margin.x = 2L, margin.y = 1L,
              extend = TRUE, adjust.labels = TRUE)



An object of class "trellis".


Integer vector specifying which conditioning variables to combine the x-axis limits over. Defaults to the second conditioning variable (rows in the default layout); that is, the limit of each packet is extended to include the limits of all other packets obtained by varying the level of the second conditioning variable (row). More than one variable can be specified; for example, margin.x = c(1, 2) would ensure that limits are extended to include all levels in both the first and second conditioning variables. In case there is a third conditioning variable, this would have the effect of per-page x-axis limits with the default layout.


Integer vector specifying which conditioning variables to combine the x-axis limits over. Similar to margin.x, but defaults to the first conditioning variable (columns in the default layout).


Logical flag indicating whether the limits should be extended after being combined. Usually a good idea.


Logical flag indicating whether labels should be removed from all but the boundaries. This may give misleading plots with non-default layouts.


combineLimits is useful mainly for plots with two conditioning variables with the default layout (columns and rows correspond to the first and second conditioning variables), when per-row and per-column limits are desired.

The lattice approach does not tie levels of the conditioning variables to the plot layout, so it is possible that all panels in a row (or column) do not represent the same level. It should be noted that combineLimits actually combines limits across levels, and not across rows and columns. Results are likely to be misleading unless the default layout is used.


An object of class "trellis"; essentially the same as x, but with certain properties modified.


Does not work for all "trellis" objects. In particular, log-scales do not yet work. Fancy layouts with skip-ped panels and unusual packet-to-panel mappings will probably also not work.


Deepayan Sarkar

See Also

Lattice, xyplot


data(Cars93, package = "MASS")

## FIXME: log scales don't yet work

pcars <- 
    xyplot(Price ~ EngineSize | reorder(AirBags, Price) + Cylinders,
           data = Cars93, 
           subset = Cylinders != "rotary" & Cylinders != "5", 
           scales = list(relation = "free",
                         y = list(log = FALSE, tick.number = 3, rot = 0)),
           xlab = "Engine Size (litres)", 
           ylab = "Average Price (1000 USD)",
           as.table = TRUE) 


useOuterStrips(combineLimits(update(pcars, grid = TRUE),
                             margin.x = c(1, 2), adjust.labels = FALSE))

useOuterStrips(combineLimits(update(pcars, grid = TRUE)))

[Package latticeExtra version 0.6-25 Index]