---
title: "Custom R plots in Vista | Oplema"
description: "Draw a custom plot in Vista with R, reading one source as a data.frame, for charts the built-in visuals don't cover. Write the code in the visual."
url: "https://oplema.com/docs/vista/developer/r"
updated: "2026-11-04"
---

# R

R draws a plot with your own code. It reads one Vista source as input\_1, a data.frame. After you edit the code, select Run to redraw it.

## Draw a bar plot with R

The default script takes the first two columns of input\_1, here Drink and Cups, and draws them with base R's barplot in steelblue. The first plot takes a while, because the R runtime has to load in your browser.

Result
| Drink | Cups |
| --- | --- |
| Tea | 20 |
| Coffee | 30 |
| Cocoa | 10 |

1. Wait for the plot to appear. Current below the code editor means the plot reflects your code.
2. In the code editor, find `col = "steelblue"` and change the color, for example to `"tomato"`.
3. Select Run. The plot redraws. Editing alone doesn't run the code.

## When to use

Use R for statistical plots when your team already writes base R graphics. The source arrives as a data.frame. If your code uses matplotlib and Polars, use Python. If a built-in chart can do the job, use it, because it loads faster.

## Inputs

1 port

**Data source**

Accepts: Tables.

Accepts one connection on this port.

## Settings

**R**

R plot code. Edit it in the R editor in Properties.

Default: `# Choose the label and value columns from your source. label_column <- names(input_1)[1] value_column <- names(input_1)[2] barplot(as.numeric(input_1[[value_column]]), names.arg = input_1[[label_column]], xlab = label_column, ylab = value_column, main = paste(value_column, "by", label_column), col = "steelblue")`

**Corner radius (px)**

Corner radius in whole logical pixels.

Default: `0`

**Border width (px)**

Border width in whole logical pixels.

Default: `0`

## R FAQs

**How do I know the plot matches my code?**

Below the code editor, Current means the plot reflects your last Run. While you wait for a run, or if one fails, the label on the plot starts with Outdated.

**Can I use install.packages()?**

No. Use the bundled libraries only.

**Why is the first R plot slow?**

The R runtime has to load in your browser before the first plot can draw.

### Chart your data. Build it in Vista.

Vista opens in your browser, with no account.

[Open Vista](https://oplema.com/editor?path=%2F%3Fopen%3Dvista) [About Vista](https://oplema.com/vista)
