How to Create an Empty Plot in R (3 Examples)

There are three common ways to create an empty plot in R:

Method 1: Create Completely Empty Plot

`plot.new()`

Method 2: Create Empty Plot with Axes

```plot(NULL, xlab="", ylab="", xaxt="n", yaxt="n",
xlim=c(0, 10), ylim=c(0, 10))```

Method 3: Create Empty Plot with Axes & Labels

```plot(NULL, ylab="y label", xlab="x label", main="title",
xlim=c(0, 10), ylim=c(0, 10))```

The following example shows how to use each method in practice.

Example 1: Create Completely Empty Plot

We can use the following code to create a completely empty plot in R:

```plot.new()
```

Here’s what the result looks like in the plotting window in RStudio:

Example 2: Create Empty Plot with Axes

We can use the following code to create an empty plot with axes in R:

```plot(NULL, xlab="", ylab="", xaxt="n", yaxt="n",
xlim=c(0, 10), ylim=c(0, 10))```

Here’s what the result looks like in the plotting window in RStudio:

Note that the xaxt and yaxt arguments suppress the tick marks on the x-axis and y-axis, respectively.

Example 3: Create Empty Plot with Axes & Labels

We can use the following code to create an empty plot with axes and labels in R:

```plot(NULL, ylab="y label", xlab="x label", main="title",
xlim=c(0, 10), ylim=c(0, 10))```

Here’s what the result looks like in the plotting window in RStudio:

The following tutorials explain how to perform other common tasks in R:

One Reply to “How to Create an Empty Plot in R (3 Examples)”

1. Tara says:

Very useful 👌 and easy to understand and learn, thank you!