Skip to contents

Create a scale bar to use for plots

Usage

scalebar(
  x = 500,
  breaks = 6,
  highlight_breaks = c(1, 6),
  title_position = c("top", "bottom"),
  flip_bar = FALSE,
  text_height = 2,
  ...
)

Arguments

x

Width of scale bar in microns. If the width is higher than 1,000 microns, the units will be converted to millimeters in the scale bar title.

breaks

Number of breaks to cut scale bar into. For example, 6 breaks will create 6 vertical lines and 5 even intervals.

highlight_breaks

Highlight specific breaks by increasing their height.

title_position

One of "top" or "bottom" for title placement

flip_bar

Should the scale bar be flipped to a vertical orientation?

text_height

Height of scale bar title

...

Parameters passed to geom_segment

Value

A ggplot object with a scalebar

Author

Ludvig Larsson

Examples


# Draw a scale bar for a 500 micron distance with 6 breaks where
# the ends are highlighted
scalebar()
#> Loading required namespace: ggfittext


# Draw a scale bar for a 1mm mm distance with 1 breaks where the
# ends and the mid point are highlighted
scalebar(breaks = 11, highlight_breaks = c(1, 6, 11))