1  Getting Started

library(rtemis.draw)

1.1 Installation

1.1.1 R-universe

install.packages(
  "rtemis.draw",
  repos = c('https://rtemis-org.r-universe.dev', 'https://cloud.r-project.org')
)

1.1.2 GitHub

pak::pak("rtemis-org/rtemis.draw")

1.2 Your first plot

Every plot is an htmlwidget: print it at the console and it opens in the IDE viewer; include it in a Quarto document or a Shiny app and it renders inline.

draw_scatter(penguins$bill_len, penguins$flipper_len, fit = "gam")

1.3 One backend per plot type

rtemis.draw renders each plot type with a high-performance JavaScript library. Which library is used is an implementation detail of the plot type, not something you select:

Backend Plot types High-level Low-level
ECharts scatter, line, bar, boxplot, histogram, density, pie, heatmap, sankey, spectrogram, gantt draw_*() EChartsOption
Sigma.js network graphs draw_network() SigmaOption
MapLibre GL choropleth maps draw_choropleth() MapLibreOption

1.4 Three ways in

The package exposes the same capability at three levels. They are layers of one system, not alternatives: each is built out of the one below it.

1.4.1 1. draw_*() functions

Data-first functions for common plots — this is what most code should use. They take vectors, data frames, or matrices, choose sensible defaults, and return a widget.

draw_boxplot(penguins$body_mass, group = penguins$species)
2026-10-02 10:32:07 Removed 2 NA values from data [boxplot_option]

Individual charts accept title, theme, width, height, element_id, and filename. draw_panels() arranges existing ECharts widgets and retains each child chart’s title and theme.

For fitted rtemis objects, use plot() or a plot_*() generic. For example, rtemis::plot_varimp(model) extracts the model’s importance records; draw_varimp(scores) starts from data you provide. See Variable importance for executable examples.

1.4.2 2. Option classes

EChartsOption, SigmaOption, and MapLibreOption are validated S7 render specs — the complete description of what to render, with type-checked properties. Build one and hand it to the single draw() generic, which dispatches on the option’s class to select the backend:

draw(EChartsOption(
  title = Title(text = "Body mass"),
  x_axis = Axis(type = "value", scale = TRUE),
  y_axis = Axis(type = "value"),
  series = LineSeries(
    data = local({
      d <- stats::density(na.omit(penguins$body_mass))
      mapply(c, d$x, d$y, SIMPLIFY = FALSE)
    }),
    show_symbol = FALSE,
    area_style = AreaStyle(opacity = 0.25)
  )
))

This is the tier to reach for when a draw_*() argument does not exist for what you want: dual axes, per-point styling, mark areas, custom tooltips.

1.4.3 3. Chart configs

A ChartConfig describes a chart as a document: which columns it binds, its semantics, its appearance — with no data inside it. It serializes to JSON, validates against a published schema, and renders through the same draw() generic:

cfg <- setup_ScatterConfig(x = "bill_len", y = "flipper_len", group = "species")
draw(cfg, data = penguins)

This is the tier that lets a chart be defined in one place and rendered in another — an IDE pane, a web app, a report.

1.5 Themes

theme controls the appearance of each individual chart. Left at its default NULL, the widget carries both a light and a dark theme and picks the one that matches the page or system setting at render time:

draw_histogram(penguins$body_mass, theme = theme_dark())
2026-10-02 10:32:08 Removed 2 NA values from x [distribution_samples]

See Themes for palettes, fonts, and full theme construction.

1.6 Saving

For ECharts charts, pass an .svg filename or call save_drawing() on a widget. SVG export requires Node.js. Network and map export is not implemented yet; see Export for the current limits.

draw_scatter(penguins$bill_len, penguins$flipper_len, filename = "penguins.svg")

See Export & serialization.

1.7 Where next

© 2026 E.D. Gennatas