Learn R Programming

ggstatsplot (version 0.6.6)

line_labeller: Adds a label to the horizontal or vertical line.

Description

Adds a label to the horizontal or vertical line.

Usage

line_labeller(
  plot,
  x,
  y,
  k = 2L,
  label.text,
  label.args = list(),
  jitter = 0.25,
  ...
)

Arguments

plot

A ggplot object in which the label needs to be displayed.

x, y

The x- and y-axes coordinates for the label.

k

Number of digits after decimal point (should be an integer) (Default: k = 2L).

label.text

The text to include in the label (e.g., "mean").

label.args

A list of additional aesthetic arguments to be passed to geom_label.

jitter

Numeric that specifies how much the label should be jittered in the vertical direction (default: 0.25). The sign will determine the direction (upwards or downwards).

...

Currently ignored.

Examples

Run this code
# NOT RUN {
# creating a basic plot
set.seed(123)
library(ggplot2)
p <- ggplot(mtcars, aes(wt, mpg)) +
  geom_point()

# adding a label
ggstatsplot:::line_labeller(
  plot = p,
  x = median(mtcars$wt),
  y = mean(mtcars$mpg),
  k = 2,
  label.args = list(color = "red"),
  label.text = "median"
)
# }

Run the code above in your browser using DataLab