How to change the resolution of a plot in base R?

R ProgrammingServer Side ProgrammingProgramming

In base R, we can save a plot as a png and pass the resolution in the same stage. The procedure to do this is creating the png image with resolution with res argument then creating the plot and using dev.off() to create the file. Check out the below examples to understand how it works.

Example1

Live Demo

> png(file="example1.png",res=100)
> plot(1:10)
> dev.off()

Output:


Example2

Live Demo

> png(file="example2.png",res=200)
> plot(1:10)
> dev.off()

Output

raja
Published on 06-Nov-2020 11:21:31
Advertisements