Skip to contents

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.

x <- c(rnorm(10000), rnorm(1000, 4, 0.5))

hchart(x, name = "data", color = "#17b8b6")

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.

data(sample_matrix, package = "xts")
hchart(xts::as.xts(sample_matrix), name = "Sample prices")

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: