1  Getting Started

library(rtemis.draw)

Attaching package: 'rtemis.draw'
The following object is masked from 'package:graphics':

    Axis

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 the most capable JavaScript library for the job. 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-08-18 16:38:06 Removed 2 NA values from data [boxplot_option]

Every draw_*() function shares the same trailing arguments: title, theme, width, height, element_id, and filename.

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 is an argument to every drawing function. 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())

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

1.6 Saving

Pass filename to any drawing function, or call save_drawing() on a widget, to write a static file:

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

See Export & serialization.

1.7 Where next

© 2026 E.D. Gennatas