Explore Charts, Stock and Maps below, then continue with the guide for the kind of chart you need. For a step-by-step tutorial on building and customizing a chart, see First steps.
Highcharts
Use hchart() to plot the Palmer penguins by species.
library(highcharter)
hchart(
palmerpenguins::penguins,
"scatter",
hcaes(x = flipper_length_mm, y = bill_length_mm, group = species)
)hchart() draws a histogram for a numeric vector.
For a forecast object, hchart() adds the predicted
values and prediction interval.
fit <- forecast::auto.arima(AirPassengers)
hchart(forecast::forecast(fit, level = 95))See more examples of hchart in
vignette("hchart").
Highstock
Highcharts Stock adds a navigator, preset date ranges and a date picker. Drag the navigator handles to change the visible period.
An xts series with open, high, low and close prices
produces a candlestick chart.
Highmaps
We can chart maps elements and choropleth using the highmaps and build interactive maps to display data linked to geographic objects.
palette <- c("#000004", "#56106E", "#BB3754", "#F98C0A", "#FCFFA4")
hcmap(
"custom/world-robinson-lowres",
data = subset(world_income, year == 2024),
value = "gni_per_capita",
joinBy = c("iso-a3", "iso3"),
name = "GNI per capita",
borderWidth = 0.2
) |>
hc_title(text = "Gross national income per capita, 2024") |>
hc_colorAxis(
type = "logarithmic",
stops = color_stops(colors = palette)
) |>
hc_tooltip(valuePrefix = "$", valueDecimals = 0)What now?
Since you know the basics now it could be interesting:
- Go motivate yourself with the
vignette("showcase")and look everything that can be done with the {highcharter} package. - Learn to configure graphics using the implemented API in
vignette("highcharts-api"). - Explore chart types and their R examples.
