SmallMultiples: Plotting data as a small multiples

View source: R/smallmultiples.R

SmallMultiplesR Documentation

Plotting data as a small multiples

Description

A small multiple (sometimes called trellis chart, lattice chart, grid chart, or panel chart) is a series of similar graphs or charts using the same scale and axes, allowing them to be easily compared.

Usage

SmallMultiples(
  x,
  chart.type = "Area",
  nrows = 2,
  share.axes = TRUE,
  pad.left = 0.01,
  pad.right = 0.01,
  pad.top = 0.01,
  pad.bottom = 0.01,
  x.order = NULL,
  average.show = FALSE,
  average.color = rgb(153, 153, 153, maxColorValue = 255),
  y.bounds.maximum = NULL,
  y.bounds.minimum = NULL,
  x.bounds.maximum = NULL,
  x.bounds.minimum = NULL,
  x.tick.maxnum = NULL,
  y.tick.maxnum = NULL,
  values.bounds.maximum = NULL,
  values.bounds.minimum = NULL,
  colors = ChartColors(max(1, ncol(x), nrow(x), na.rm = TRUE)),
  fit.line.colors = colors,
  fit.CI.colors = colors,
  global.font.family = "Arial",
  global.font.color = rgb(44, 44, 44, maxColorValue = 255),
  title = "",
  title.font.family = global.font.family,
  title.font.color = global.font.color,
  title.font.size = 16,
  title.align = "center",
  subtitle = "",
  subtitle.font.family = global.font.family,
  subtitle.font.color = global.font.color,
  subtitle.font.size = 12,
  subtitle.align = "center",
  footer = "",
  footer.font.family = global.font.family,
  footer.font.color = global.font.color,
  footer.font.size = 8,
  footer.align = "center",
  footer.wrap = TRUE,
  footer.wrap.nchar = 100,
  panel.title.show = TRUE,
  panel.title.font.family = global.font.family,
  panel.title.font.color = global.font.color,
  panel.title.font.size = 14,
  panel.title.wrap = TRUE,
  panel.title.wrap.nchar = 20,
  x.title = "",
  x.title.font.size = 12,
  y.title = "",
  y.title.font.size = 12,
  data.label.show = FALSE,
  data.label.prefix = "",
  data.label.suffix = "",
  data.label.format = "",
  data.label.font.size = 10,
  data.label.font.color = global.font.color,
  hovertext.template = NULL,
  line.thickness = NULL,
  x.tick.show = TRUE,
  x.tick.angle = NULL,
  legend.show = TRUE,
  margin.autoexpand = TRUE,
  margin.left = NULL,
  margin.right = NULL,
  margin.top = NULL,
  margin.bottom = NULL,
  mapping.package = "plotly",
  scatter.x.column = 1,
  scatter.y.column = 2,
  scatter.sizes.column = 3,
  scatter.colors.column = 4,
  scatter.groups.column = NULL,
  scatter.colors.as.categorical = TRUE,
  scatter.sizes.as.diameter = FALSE,
  ...
)

Arguments

x

Input data as a matrix or dataframe

chart.type

Can be one of "Area", "Column", "Bar", "Line", "Radar" or "Geographic Map".

nrows

Integer; Number of rows to arrange the charts in

share.axes

Force range of the plot to be the same across all panels.

pad.left

Numeric in [0,1]; Spacing to the left of chart (between panels)

pad.right

Numeric in [0,1]; Spacing to the right chart (between panels)

pad.top

Numeric in [0,1]; Spacing above chart (between panels)

pad.bottom

Numeric in [0,1]; Spacing below chart (between panels)

x.order

A vector containing the list index of the columns in the order which they are to be shown

average.show

Logical; whether to show a second series in each panel containing the data averaged across all series.

average.color

The color in which the average series should be displayed

y.bounds.maximum

Maximum of range for plotting; NULL = no manual range set.

y.bounds.minimum

Minimum of range for plotting; For a date axis this should be supplied as a date string. For a categorical axis, the index of the category (0-based) should be used.

x.bounds.maximum

Maximum of range for plotting; NULL = no manual range set. Must be greater than x.bounds.minimum

x.bounds.minimum

Minimum of range for plotting; For a date axis this should be supplied as a date string. For a categorical axis, the index of the category (0-based) should be used.

x.tick.maxnum

Maximum number of ticks shown on the axis. It defaults to 11 which gives the same output from plotly as NULL. This setting is ignored if x.tick.distance is set or if the axis is categorical

y.tick.maxnum

Maximum number of ticks shown on the axis. This setting is ignored if y.tick.distance is set or if the axis is categorical

values.bounds.maximum

Numeric; specifies the maximum value in the colorscale.

values.bounds.minimum

Numeric; specifies the minimum value in the colorscale. If not specified, this will be automatically determined from the data. If the value specified is larger than the minimum in the data then the specified value will be ignored.

colors

Character; a vector containing one or more colors specified as hex codes.

fit.line.colors

Character; a vector containing one or more colors specified as hex codes.

fit.CI.colors

Character; a vector containing one or more colors specified as hex codes.

global.font.family

Character; font family for all occurrences of any font attribute for the chart unless specified individually.

global.font.color

Global font color as a named color in character format (e.g. "black") or an a hex code.

title

Character; chart title.

title.font.family

Character; title font family. Can be "Arial Black", "Arial", "Comic Sans MS", "Courier New", "Georgia", "Impact", "Lucida Console", "Lucida Sans Unicode", "Marlett", "Symbol", "Tahoma", "Times New Roman", "Trebuchet MS", "Verdana", "Webdings"

title.font.color

Title font color as a named color in character format (e.g. "black") or a hex code.

title.font.size

Integer; Title font size; default = 10.

title.align

Horizontal alignment of title.

subtitle

Character

subtitle.font.family

Character; subtitle font family

subtitle.font.color

subtitle font color as a named color in character format (e.g. "black") or an a hex code.

subtitle.font.size

Integer; subtitle font size

subtitle.align

Horizontal alignment of subtitle.

footer

Character

footer.font.family

Character; footer font family

footer.font.color

footer font color as a named color in character format (e.g. "black") or an a hex code.

footer.font.size

Integer; footer font size

footer.align

Horizontal alignment of footer.

footer.wrap

Logical; whether the footer text should be wrapped.

footer.wrap.nchar

Number of characters (approximately) in each line of the footer when footer.wrap TRUE.

panel.title.show

Logical; whether to show a title for each panel.

panel.title.font.family

Font family of panel titles.

panel.title.font.color

Font color of panel titles.

panel.title.font.size

Font size of panel titles.

panel.title.wrap

Logical; whether the panel title should be wrapped.

panel.title.wrap.nchar

Number of characters (approximately) in each line of the panel title when panel.title.wordwrap TRUE.

x.title

Character, x-axis title; defaults to chart input values; to turn off set to "FALSE".

x.title.font.size

Integer; x-axis title font size

y.title

Character, y-axis title; defaults to chart input values; to turn off set to "FALSE".

y.title.font.size

Integer; y-axis title font size

data.label.show

Logical; whether to show data labels.

data.label.prefix

Character; prefix for data values.

data.label.suffix

Character; suffix for data values.

data.label.format

A string representing a d3 formatting code. See https://github.com/mbostock/d3/wiki/Formatting#numbers

data.label.font.size

Integer; Font size for data label.px.

data.label.font.color

Font color as a named color in character format (e.g. "black") or an a hex code. This can be a single color, a vector of colors (1 for each series/column), or a comma separated list of colors

hovertext.template

Specify format of the hovertext. This can be a string or matrix which is the same dimensions as chart.matrix. If no format is specified the default is for categorical x-axis "%x: %y" or for a numerical x-axis "(%x, %y)".

line.thickness

Thickness, in pixels, of the series line

x.tick.show

Whether to display the x-axis tick labels

x.tick.angle

x-axis tick label angle in degrees. 90 = vertical; 0 = horizontal

legend.show

Ignored except for with GeographicMap.

margin.autoexpand

Logical; Whether extra space can be added to the margins to allow space for axis/legend/data labels or other chart elements.

margin.left

Margin between plot area and the left of the graphic in pixels

margin.right

Margin between plot area and the right of the graphic in pixels

margin.top

Margin between plot area and the top of the graphic in pixels

margin.bottom

Margin between plot area and the bottom of the graphic in pixels

mapping.package

Not used.

scatter.x.column

When x is a dataframe or matrix, the index of the column (1-based) which contains the x-coordinate data.

scatter.y.column

When x is a dataframe or matrix, the index of the column (1-based) which contains the y-coordinate data.

scatter.sizes.column

When x is a dataframe or matrix, the index of the column (1-based) which contains scatter.sizes data.

scatter.colors.column

When x is a dataframe or matrix, the index of the column (1-based) which contains scatter.colors data.

scatter.groups.column

The column of x which is used to aggregate the data for small multiples. By default this is the last column in x

scatter.colors.as.categorical

Boolean; Whether to treat colors as a categorical groups, or a numeric scale.

scatter.sizes.as.diameter

Whether to show the points with diameter (instead of area, which is the default) proportional to the sizes variable.

...

Extra arguments passed to the charting function

Value

an HTML widget for "leaflet" or a "plotly" object.

Examples

x <- matrix(1:21, 7, 3, dimnames = list(letters[1:7], LETTERS[1:3]))
SmallMultiples(x, "Column", colors=c("red","green","blue"))

NumbersInternational/flipStandardCharts documentation built on Feb. 26, 2024, 5:43 a.m.