Penz
Penz

Reputation: 5648

R - How to draw an empty plot with no height?

I can make an empty plot in R by using:

plot.new()

That create a blank plot with the default width and height.

I want to create an empty plot with minimal height. I tried png('z.png', height=1), but that got me:

> png('x.png', height=1)
> plot.new()
Error in plot.new() : figure margins too large

How can I create such a plot? I guess I have to zero the margins too.

Upvotes: 2

Views: 276

Answers (1)

ialm
ialm

Reputation: 8727

Well... I don't know why you would want to do this, but here goes:

# Make a png file
png('x.png', height=1)

# Change the margins of the plot to 0 on each side
par(mar=rep(0,4))

# Make an empty plot
plot.new()

# Close the connection to the png file
dev.off()

Upvotes: 3

Related Questions