add-vh-lines | R Documentation |
Add horizontal or vertical line
add_hline(ax, value, color = "#000", dash = 0, label = NULL, ...)
add_vline(ax, value, color = "#000", dash = 0, label = NULL, ...)
ax |
An |
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 |
label |
Add a label to the shade, use a |
... |
Additional arguments, see https://apexcharts.com/docs/options/annotations/ for possible options. |
An apexchart()
htmlwidget
object.
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"
)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.