Description Usage Arguments Details Examples
View source: R/geom_scalebar.R
Creates a scale bar in a ggplot
| 1 | geom_scalebar(range, y, segments, size)
 | 
| range | A vector with two values. Giving the limits in x direction. It doesn't matter which value comes first (if it's not important which colour the first segment has). | 
| y | Value for vertical positioning. | 
| segments | Specifies the number of segments between lower and upper range. | 
| size | Specifies the width of the scale bar. | 
Uses geom_segment to create a black and white scale bar in horizontal direction. Is not able to give any information about the magnification itself! The exact length of the scale bar has to be known.
| 1 2 3 4 5 6 7 8 | #rm(list = ls())
ggplot2::ggplot(data = NULL, ggplot2::aes(x = c(2,5), y = c(3, 1))) +
   ggplot2::geom_point() +
   geom_scalebar(range = c(2.5, 4.5), y = 2, segments = 4, size = 2)
ggplot2::ggplot(data = NULL, ggplot2::aes(x = c(2,5), y = c(3, 1))) +
   ggplot2::geom_point() +
   geom_scalebar(range = c(4.5, 2.5), y = 2, segments = 4, size = 2)
 | 
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.