mark-area | R Documentation |
Add a rectangle annotation to a chart
v_mark_rect(
vc,
xmin = NULL,
xmax = NULL,
ymin = NULL,
ymax = NULL,
.area.style.fill = "grey35",
.area.style.fillOpacity = 0.3,
.label.text = NULL,
.label.position = "insideTop",
.label.refY = 0,
.label.refX = 0
)
v_mark_polygon(
vc,
coords,
.area.style.fill = "grey35",
.area.style.fillOpacity = 0.3,
.label.text = NULL,
.label.position = "insideTop",
.label.refY = 0,
.label.refX = 0
)
vc |
An htmlwidget created with |
xmin , xmax , ymin , ymax |
Target position for the rectangle. Use |
.area.style.fill |
Fill color. |
.area.style.fillOpacity |
Fill opacity. |
.label.text |
Text for the label on the line. |
.label.position |
The label position of the dimension line (the relative position of the label relative to the line). See online documentation for options. |
.label.refY , .label.refX |
The offset in the vertical direction of the reference line. |
coords |
A |
A vchart()
htmlwidget
object.
library(vchartr)
# Draw a rectangle
vchart(cars) %>%
v_scatter(aes(speed, dist)) %>%
v_mark_rect(
xmin = 10,
xmax = 18,
ymin = 20,
ymax = 50
)
# don't provide x or y to reach chart's limit
vchart(cars) %>%
v_scatter(aes(speed, dist)) %>%
v_mark_rect(
xmin = 10,
xmax = 18
)
vchart(cars) %>%
v_scatter(aes(speed, dist)) %>%
v_mark_rect(
ymin = 10,
ymax = 18
)
vchart(cars) %>%
v_scatter(aes(speed, dist)) %>%
v_mark_rect(
xmin = "50%",
xmax = "100%", # from right to left
ymin = "50%",
ymax = "100%" # note that for y it's from top to bottom
)
# Whith date scale
vchart(temperatures) %>%
v_line(aes(date, average)) %>%
v_mark_rect(
xmin = as.Date("2024-06-20"),
xmax = as.Date("2024-09-22"),
.label.text = "Summer"
)
# Draw a polygon
vchart(cars) %>%
v_scatter(aes(speed, dist)) %>%
v_mark_polygon(
coords = list(
x = c(7, 22, 15),
y = c(10, 50, 80)
)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.