geom_coltext: Bar Plot with Numbers at the Ends of the Bars. Options not...

Description Usage Arguments Format Examples

Description

Bar Plot with Numbers at the Ends of the Bars. Options not mentioned here work identical to geom_col or geom_text.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
geom_coltext(mapping = NULL, data = NULL, position = "dodge", ...,
  stat = "identity", width = NULL, center_text = FALSE,
  just_mirror = TRUE, just_mirror_cutoff = c(0.1, 0.9),
  fontcolor = c(STAT.UP.Grey, STAT.UP.Lightgrey), parse = FALSE,
  na.rm = FALSE, show.legend = NA, inherit.aes = TRUE)

geom_bartext(mapping = NULL, data = NULL, position = "dodge", ...,
  stat = "identity", width = NULL, center_text = FALSE,
  just_mirror = TRUE, just_mirror_cutoff = c(0.1, 0.9),
  fontcolor = c(STAT.UP.Grey, STAT.UP.Lightgrey), parse = FALSE,
  na.rm = FALSE, show.legend = NA, inherit.aes = TRUE)

GeomColtext

Arguments

mapping
data
position
...
width
center_text

Logical value. If TRUE the text will be centered within its respective bar.

just_mirror

Logical value. If TRUE then the justification of the text will be mirrored at the edge of the bar for the largest and smallest values (see just_mirror_cutoff below). E.g. if the text is outside the bars then for the largest values it will be inside the bars. This prevents text from being cut off by the edges of the plot.

just_mirror_cutoff

Two numeric values between 0 and 1. The default of 0.9 for the second value means that if the text is supposed to appear outside the bars then for values larger (in absolute terms) than 90 flipped to appear inside. And vice versa for text inside bars and the first value of just_mirror_cutoff. This avoids text getting cutoff by the edge of the plot or text obscuring the bars for very small values. Set it to 0 or 1 to switch off.

fontcolor

Character vector of color specifications (names, hex-values, etc.). For text appearing inside the bars the geom will use the value "most unlike" the bar color. There are some limits to this and bugs to be found.

parse
na.rm
show.legend
inherit.aes

Relevant aes are

  • x

  • y

  • label - y is used otherwise

The following aes are passed to geom_col

  • color

  • fill

  • size

  • linetype

  • alpha

The following aes are used by geom_text

  • fontsize - the size aes of geom_text

  • angle

  • injust - like hjust and vjust but it represents the "inward" justification. A value of -1 will be just outside and a value of 1 just inside the bar border.

  • family

  • fontface

  • lineheight

Format

An object of class GeomColtext (inherits from GeomRect, Geom, ggproto) of length 5.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
library(ggplot2)

X <- data.frame(x = 1:5, y = sample(1:100, 5))

ggplot(X, aes(x, y)) +
  geom_coltext(injust = -1.5)

ggplot(X, aes(x, y)) +
  geom_coltext(injust = 1.5)

ggplot(X, aes(x, y)) +
  geom_coltext(injust = 1.5) +
  coord_flip()

ggplot(X, aes(x, y, label = percentify(y))) +
  geom_coltext(injust = -1.5) +
  coord_flip()

STAT-UP/statupinternal documentation built on May 9, 2019, 11:43 a.m.