R – How to resize and save plots in png format

plotr

I would like to plot the results from a quantile regression, but am not able to:

  1. control the dimensions/size of the plots and
  2. save the plots as png.

Here is my code:

require(quantreg)
data(engel)
attach(engel)
xx <- income - mean(income)
zz <- c(120, diff(income))
fit1 <- summary(rq(foodexp~xx+zz, tau=2:98/100))

Then:

png('res.png')
plot(fit1, mfrow=c(1,2))

Only the zz plot is saved to the res.png file.. Is there any way I can save the plots in separate files (two and one)?
and how do I control the width/height of the plots? I like all the individual plots to have width=height (square) when i save them to the .png file?

Best Solution

You can control the image dimensions by png argument.

png("image.png", width = 800, height = 600)
plot(...)
dev.off()

To "finish" the image, use dev.off.

Related Question