v_hist | R Documentation |
Create an Histogram
v_hist(
vc,
mapping = NULL,
data = NULL,
name = NULL,
stack = FALSE,
bins = 30,
binwidth = NULL,
...,
serie_id = NULL,
data_id = NULL
)
vc |
A chart initialized with |
mapping |
Default list of aesthetic mappings to use for chart. |
data |
Default dataset to use for chart. If not already
a |
name |
Name for the serie, only used for single serie (no |
stack |
Whether to stack the data or not (if |
bins |
Number of bins. Overridden by |
binwidth |
The width of the bins. Can be specified as a numeric value
or as a function that calculates width from unscaled x. Here, "unscaled x"
refers to the original x values in the data, before application of any
scale transformation. When specifying a function along with a grouping
structure, the function will be called once per group.
The default is to use the number of bins in The bin width of a date variable is the number of days in each time; the bin width of a time variable is the number of seconds. |
... |
Additional properties for histogram bars. |
data_id , serie_id |
ID for the data/serie, can be used to further customize the chart with |
A vchart()
htmlwidget
object.
library(vchartr)
library(palmerpenguins)
# Create an histogram using a numeric variable
vchart(penguins) %>%
v_hist(aes(flipper_length_mm))
# Customize some style properties
vchart(penguins) %>%
v_hist(
aes(flipper_length_mm),
bar = list(
style = list(
stroke = "white",
line_width = 1,
fill = "forestgreen"
)
)
)
# Use fill aesthetic to differentiate series
vchart(penguins) %>%
v_hist(aes(flipper_length_mm, fill = species))
# Stack results
vchart(penguins) %>%
v_hist(aes(flipper_length_mm, fill = species), stack = TRUE)
# Use custom colors
vchart(penguins) %>%
v_hist(
aes(flipper_length_mm, fill = species),
bar = list(
style = list(opacity = 0.5)
)
) %>%
v_scale_color_manual(c(
Adelie = "#ffa232",
Chinstrap = "#33a2a2",
Gentoo = "#b34df2"
))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.