Create a Scatter Chart
v_scatter.Rd
Create a Scatter Chart
Usage
v_scatter(
vc,
mapping = NULL,
data = NULL,
name = NULL,
...,
serie_id = NULL,
data_id = NULL
)
Arguments
- vc
A chart initialized with
vchart()
.- mapping
Default list of aesthetic mappings to use for chart.
- data
Default dataset to use for chart. If not already a
data.frame
, it will be coerced to withas.data.frame
.- name
Name for the serie, only used for single serie (no
color
/fill
aesthetic supplied).- ...
Additional parameters for the serie.
- data_id, serie_id
ID for the data/serie, can be used to further customize the chart with
v_specs()
.
Value
A vchart()
htmlwidget
object.
Examples
library(vchartr)
data("penguins", package = "palmerpenguins")
# Basic scatter chart
vchart(penguins) %>%
v_scatter(aes(x = flipper_length_mm, y = body_mass_g))
# Color series with discrete values
vchart(penguins) %>%
v_scatter(aes(x = flipper_length_mm, y = body_mass_g, color = species))
# Color series with continuous values
vchart(penguins) %>%
v_scatter(aes(x = bill_length_mm, y = bill_depth_mm, color = body_mass_g))
# Size of points
vchart(penguins) %>%
v_scatter(aes(x = bill_length_mm, y = bill_depth_mm, size = body_mass_g))
# Size and color
vchart(penguins) %>%
v_scatter(aes(
x = bill_length_mm,
y = bill_depth_mm,
color = body_mass_g,
size = body_mass_g
))
# With shapes
vchart(penguins) %>%
v_scatter(
aes(
x = bill_length_mm,
y = bill_depth_mm,
color = species,
shape = species
)
)
vchart(penguins) %>%
v_scatter(
aes(x = flipper_length_mm, y = body_mass_g, color = species)
) %>%
v_scale_color_manual(c(
Adelie = "#ffa232",
Chinstrap = "#33a2a2",
Gentoo = "#b34df2"
))