开发者

How to resize and save plots in png format?

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=开发者_如何学Go2: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?


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.


For subdividing the plots:

plot(fit1,parm=1:2)
plot(fit1,parm=3)

Note that you could have found the answer by careful reading of ?plot.summary.rqs, but this may not have been obvious: in order to know where to look you would need to do class(fit1) to figure out which plot method was being used.

Roman's answer takes care of the image dimension stuff.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜