Lo_Lo
2009-Mar-23 14:38 UTC
[R] how to save a plot in a given size in inches or centimeters
Hi there ! I'm ploting graphics and I'd like to save them as a .jpeg file for example, but with a given size (in inches or cm). I tryed the function windows() but I think it just changes the size of the window and not the size of the graph that you're saving. Then I tryed with the function par(din=(width=... height=...) ) but I guess it's protected and I can't change the values. Finally I tryed with jpeg(file, units="in", width=..., height=...) but R asks me for another argument "res" that is supposed to be res=72 dpi or res=NA (I found those values in the R-help). It still doesn't work... Because of problems of margin, or "can't create a bitmap file" or something different again... Could you give me some advice guys ? It sounds basic to me :) but I'm stupidly trapped and I can't find any solutions !! Thanks a lot -- View this message in context: http://www.nabble.com/how-to-save-a-plot-in-a-given-size-in-inches-or-centimeters-tp22656478p22656478.html Sent from the R help mailing list archive at Nabble.com.
stephen sefick
2009-Mar-23 14:43 UTC
[R] how to save a plot in a given size in inches or centimeters
isn't there a width height argument in the jpeg function? ?jpeg I am probably wrong, Stephen Sefick On Mon, Mar 23, 2009 at 10:38 AM, Lo_Lo <tchibadou at hotmail.com> wrote:> > Hi there ! > > I'm ploting graphics and I'd like to save them as a .jpeg file for example, > but with a given size (in inches or cm). > > I tryed the function windows() but I think it just changes the size of the > window and not the size of the graph that you're saving. > > Then I tryed with the function par(din=(width=... height=...) ) but I guess > it's protected and I can't change the values. > > Finally I tryed with jpeg(file, units="in", width=..., height=...) but R > asks me for another argument "res" that is supposed to be res=72 dpi or > res=NA (I found those values in the R-help). It still doesn't work... > Because of problems of margin, or "can't create a bitmap file" or something > different again... > > Could you give me some advice guys ? It sounds basic to me :) but I'm > stupidly trapped and I can't find any solutions !! > > Thanks a lot > -- > View this message in context: http://www.nabble.com/how-to-save-a-plot-in-a-given-size-in-inches-or-centimeters-tp22656478p22656478.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >-- Stephen Sefick Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis
David M Smith
2009-Mar-23 15:38 UTC
[R] how to save a plot in a given size in inches or centimeters
On Mon, Mar 23, 2009 at 7:38 AM, Lo_Lo <tchibadou at hotmail.com> wrote:> I'm ploting graphics and I'd like to save them as a .jpeg file for example, > but with a given size (in inches or cm). > > I tryed the function windows() but I think it just changes the size of the > window and not the size of the graph that you're saving. > > Then I tryed with the function par(din=(width=... height=...) ) but I guess > it's protected and I can't change the values. > > Finally I tryed with jpeg(file, units="in", width=..., height=...) but R > asks me for another argument "res" that is supposed to be res=72 dpi or > res=NA (I found those values in the R-help). It still doesn't work... > Because of problems of margin, or "can't create a bitmap file" or something > different again... > > Could you give me some advice guys ? It sounds basic to me :) but I'm > stupidly trapped and I can't find any solutions !! > > Thanks a lotYou'll be wanting to call the jpeg() function directly with the widthand height= arguments. These are given in pixels, which makes things a little tricky if you want to measure in inches -- you'll need also use the "res" argument to set the resolution. See: http://blog.revolution-computing.com/2009/01/10-tips-for-making-your-r-graphics-look-their-best.html for some examples. I'm guessing you want to print your graphic in which case jpeg() probably isn't the best choice (it rarely is for statistical graphics). See that same post for some other suggestions. # David Smith -- David M Smith <david at revolution-computing.com> Director of Community, REvolution Computing www.revolution-computing.com Tel: +1 (206) 577-4778 x3203 (Seattle, USA) Check out our upcoming events schedule at www.revolution-computing.com/events