Movatterモバイル変換


[0]ホーム

URL:


Skip to contents

Lay out panels in a ragged grid

Source:R/facet_ragged.R,R/facet_ragged_rows.R,R/facet_ragged_cols.R
facet_ragged.Rd

These facets create layouts in-betweenggplot2::facet_wrap() andggplot2::facet_grid(). Panels are arranged into groups stacked along thedefining dimension, but remain independent in the other dimension, allowingfor a grid with ragged edges. This can be useful, for example, to representnested or partially crossed relationships between faceting variables.

Usage

facet_ragged_rows(rows,cols,...,  scales="fixed",  switch="none",  strips="margins",  axes="margins",  align="start",  labeller="label_value")facet_ragged_cols(rows,cols,...,  scales="fixed",  switch="none",  strips="margins",  axes="margins",  align="start",  labeller="label_value")

Arguments

rows, cols

A set of variables or expressions quoted byggplot2::vars(),the combinations of which define the panels in the layout.

...

Arguments reserved for future use.

scales

Determines which panels share axis ranges. By default ("fixed"),all panels share the same scales. Use"free_x" to let x-axes vary, use"free_y" to let y-axes vary, or"free" to let both axes vary. Panelswithin groups always share the scale along the grouping dimension.

switch

Determines how facet label strips are positioned. By default("none"), strips are drawn to the top and right of the panels. Use"x"to switch the top strip to the bottom, use"y" to switch the right stripto the left, or"both" to do both.

strips

Determines which facet label strips are drawn. By default("margins"), strips between panels along the grouping dimension will besuppressed. Use"all" to always draw both strips.

axes

Determines which axes are drawn. By default ("margins"), axesbetween panels will be suppressed if they are fixed. Use"all_x" toalways draw x-axes,"all_y" to always draw y-axes, or"all" to alwaysdraw both axes.

align

Determines how panels are positioned within groups. By default("start"), panels in groups are densely packed from the start. Use"end" to instead pack panels to the end of the group.

labeller

A function that takes one data frame of labels andreturns a list or data frame of character vectors. Each inputcolumn corresponds to one factor. Thus there will be more thanone withvars(cyl, am). Each outputcolumn gets displayed as one separate line in the striplabel. This function should inherit from the "labeller" S3 classfor compatibility withlabeller(). You can use different labelingfunctions for different kind of labels, for example uselabel_parsed() forformatting facet labels.label_value() is used by default,check it for more details and pointers to other options.

Value

AFacet that can be added to aggplot.

Examples

p<-ggplot(mpg,aes(displ,cty))+geom_point()p+facet_ragged_rows(vars(drv),vars(cyl))p+facet_ragged_cols(vars(cyl),vars(drv))# \donttest{# Allow axes to vary between panelsp+facet_ragged_rows(vars(drv),vars(cyl), scales="free_y")p+facet_ragged_rows(vars(drv),vars(cyl), scales="free")# Change strip label positionsp+facet_ragged_rows(vars(drv),vars(cyl), switch="y")p+facet_ragged_rows(vars(drv),vars(cyl), switch="both")# Draw strips between panelsp+facet_ragged_rows(vars(drv),vars(cyl), strips="all")# Draw axes between panelsp+facet_ragged_rows(vars(drv),vars(cyl), axes="all_x")p+facet_ragged_rows(vars(drv),vars(cyl), axes="all")# }# Change panel alignmentp+facet_ragged_rows(vars(drv),vars(cyl), align="end")

[8]ページ先頭

©2009-2025 Movatter.jp