add-vh-lines: Add horizontal or vertical line

add-vh-linesR Documentation

Add horizontal or vertical line

Description

Add horizontal or vertical line

Usage

add_hline(ax, value, color = "#000", dash = 0, label = NULL, ...)

add_vline(ax, value, color = "#000", dash = 0, label = NULL, ...)

Arguments

ax

An apexchart() htmlwidget object.

value

Vector of position for the line(s).

color

Color(s) of the line(s).

dash

Creates dashes in borders of SVG path. A higher number creates more space between dashes in the border. Use 0 for plain line.

label

Add a label to the shade, use a character or see label for more controls.

...

Additional arguments, see https://apexcharts.com/docs/options/annotations/ for possible options.

Value

An apexchart() htmlwidget object.

Examples


library(apexcharter)

# On a column chart
unhcr_ts %>%
  subset(year == 2017 & population_type == "Asylum-seekers") %>%
  apex(
    aes(continent_origin, n),
    "column"
  ) %>%
  add_hline(value = 5e5)


# On a scatter chart
apex(
  data = cars,
  aes(speed, dist),
  "scatter"
) %>%
  add_hline(value = mean(cars$dist)) %>%
  add_vline(value = mean(cars$speed))

# With labels
apex(
  data = cars,
  aes(speed, dist),
  "scatter"
) %>%
  add_hline(
    value = mean(cars$dist),
    label = "Mean of dist"
  ) %>%
  add_vline(
    value = mean(cars$speed),
    label = label(
      text = "Mean of speed",
      borderColor = "red"
    )
  )

apexcharter documentation built on July 9, 2023, 7:55 p.m.