Skip to main content

28  Visualization

rtemis model plots use rtemis.draw. The plotting methods extract recorded predictions, metrics, or importance values and return interactive graphics. The rtemis.draw::draw_*() functions plot data directly. Examples use an explicit package namespace to identify the plotting interface.

28.1 Inspect a fitted model

rows <- c(1:40, 51:90, 101:140)
mod <- train(
  iris[rows, ],
  dat_test = iris[-rows, ],
  hyperparameters = setup_CART(),
  execution_config = setup_SerialExecution(seed = 2026L)
)
2026-11-04 18:51:50 Checking data is ready for training... ✔ [check_supervised]
2026-11-04 18:51:50 ▶ [train]
2026-11-04 18:51:50 Training set: 120 cases x 4 features. [summarize_supervised]
2026-11-04 18:51:50     Test set: 30 cases x 4 features. [summarize_supervised]
2026-11-04 18:51:50 // CPU | serial | 1 worker: algorithm 1 thread, tuning 1, outer resampling 1 [msg_resources]
2026-11-04 18:51:50 Shared memory (auto): not sharing training data (6.6 kB) -- this run transfers nothing to workers. [report_shared_memory]
2026-11-04 18:51:50 Training CART Classification... [train]
2026-11-04 18:51:51 Checking data is ready for training... ✔ [check_supervised]

<Classification>
CART (CART decision tree (rpart))

  <Training Classification Metrics>
                     Predicted
          Reference  setosa  versicolor  virginica  
             setosa      40           0          0
         versicolor       0          39          1
          virginica       0           0         40

                     Overall  
  Balanced Accuracy  0.992  
                 F1  0.992  
           Accuracy  0.992  
                     Setosa  Versicolor  Virginica  
        Sensitivity  1.000   0.975       1.000    
        Specificity  1.000   1.000       0.988    
  Balanced Accuracy  1.000   0.988       0.994    
                PPV  1.000   1.000       0.976    
                NPV  1.000   0.988       1.000    
                 F1  1.000   0.987       0.988    

  <Test Classification Metrics>
                     Predicted
          Reference  setosa  versicolor  virginica  
             setosa      10           0          0
         versicolor       0          10          0
          virginica       0           0         10

                     Overall  
  Balanced Accuracy  1.000  
                 F1  1.000  
           Accuracy  1.000  
                     Setosa  Versicolor  Virginica  
        Sensitivity  1.000   1.000       1.000    
        Specificity  1.000   1.000       1.000    
  Balanced Accuracy  1.000   1.000       1.000    
                PPV  1.000   1.000       1.000    
                NPV  1.000   1.000       1.000    
                 F1  1.000   1.000       1.000    

2026-11-04 18:51:51 Done in 0.30 seconds. [train]
plot_true_pred(mod)
plot_varimp(mod)

plot_true_pred() displays observed and predicted outcomes. For binary classification, plot_roc() displays discrimination over thresholds, and plot_pr() displays precision against recall for the positive class. present() combines a textual model summary with visual output.

28.2 Plot data directly

rtemis.draw::draw_scatter(
  iris[["Sepal.Length"]], iris[["Petal.Length"]], group = iris[["Species"]]
)
rtemis.draw::draw_histogram(iris[["Sepal.Length"]])

The rtemis.draw guide covers density, scatter, line, bar, distribution, and spatial displays. Model plots and data-level functions use the same rendering system.

28.3 Three-dimensional plots

draw_scatter3d() uses perspective projection. distance controls the camera distance, while alpha and beta control elevation and azimuth. Setting projection = "orthographic" preserves parallel lines; view_size controls its viewing extent. SVG export uses the configured initial camera.

rtemis.draw::draw_scatter3d(
  iris[, 1:3], group = iris[["Species"]], title = "Iris measurements"
)

28.4 Heatmaps

rtemis.draw::draw_heatmap(cor(iris[, 1:4]), zlim = c(-1, 1))

28.5 Distributions and categories

rtemis.draw::draw_bar() displays category summaries. rtemis.draw::draw_boxplot() displays distributions across groups. The plotting guide provides examples and axis, legend, and annotation controls.

28.6 Export

ECharts figures can be exported as SVG through rtemis.draw::save_drawing(); SVG export requires Node.js. Interactive widgets can be embedded in Quarto. See themes and Quarto output.

© 2026 E.D. Gennatas