Skip to contents

Legend charts are small charts that are added to the map, usually in addition to legends.

Usage

tm_chart_histogram(
  breaks,
  plot.axis.x,
  plot.axis.y,
  extra.ggplot2,
  position,
  width,
  height,
  stack,
  z,
  group.frame,
  resize_as_group
)

tm_chart_bar(
  plot.axis.x,
  plot.axis.y,
  extra.ggplot2,
  position,
  width,
  height,
  stack,
  z,
  group.frame,
  resize_as_group
)

tm_chart_donut(position, width, height, stack, z, group.frame, resize_as_group)

tm_chart_violin(
  position,
  width,
  height,
  stack,
  z,
  group.frame,
  resize_as_group
)

tm_chart_box(position, width, height, stack, z, group.frame, resize_as_group)

tm_chart_none()

tm_chart_heatmap(
  position,
  width,
  height,
  stack,
  z,
  group.frame,
  resize_as_group
)

Arguments

breaks

The breaks of the bins (for histograms)

plot.axis.x, plot.axis.y

Should the x axis and y axis be plot?

extra.ggplot2

Extra ggplot2 code

position

An object created with tm_pos_in() or tm_pos_out(). Or, as a shortcut, a vector of two values, specifying the x and y coordinates. The first is "left", "center" or "right" (or upper case, meaning tighter to the map frame), the second "top", "center" or "bottom". Numeric values are also supported, where 0, 0 means left bottom and 1, 1 right top. See also vignette about positioning.

width, height

width and height of the component.

stack

stack with other map components, either "vertical" or "horizontal".

z

z index, e.g. the place of the component relative to the other componets

group.frame

put frame around all components that are drawn on the same location. Whether a frame is drawn is still decided by the frame argument of the 'main' (first) component.

resize_as_group

in case a component if rescaled because of the limited space, rescale the other components proportionally?

Details

Note that these charts are different from charts drawn inside the map. Those are called glyphs (to be implemented).

Examples

tm_shape(World) +
  tm_polygons("HPI",
    fill.scale = tm_scale_intervals(),
    fill.chart = tm_chart_histogram())