library(gglite)
df = data.frame(x = c('A', 'B', 'C'), y = c(3, 7, 2))
p = g2(df, y ~ x)
Use style_mark() to set visual properties on the most recently added mark.
The following bar chart in its default style is used as the baseline for the
bar examples below.
p
p |> style_mark(fill = 'tomato', stroke = '#333', lineWidth = 3)
g2(mtcars, hp ~ mpg) |>
style_mark(fill = 'orange', stroke = '#333', lineWidth = 3)
df_line = data.frame(x = 1:10, y = c(3, 1, 4, 1, 5, 9, 2, 6, 5, 3))
p_area = g2(df_line, y ~ x) |> mark_area()
p_area |> style_mark(fill = 'steelblue', fillOpacity = 0.3)
p_line = g2(df_line, y ~ x) |> mark_line()
p_line |> style_mark(stroke = 'tomato', lineWidth = 3)
p_line |> style_mark(stroke = 'steelblue', lineDash = c(6, 3))