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


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

Updated on: 06-Nov-2020

2K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements