[R] Graphical Parameters

0 views
Skip to first unread message

mohsin ali

unread,
Aug 17, 2009, 1:54:18 AM8/17/09
to r-h...@r-project.org

Hi Sir

How can I change plot size, figure size and device size? The examples availble for par() function are not very helpful. Would you please give a very simple example?

Best Regards

_________________________________________________________________
Show them the way! Add maps and directions to your party invites.

[[alternative HTML version deleted]]

______________________________________________
R-h...@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.

Jim Lemon

unread,
Aug 17, 2009, 7:42:32 AM8/17/09
to mohsin ali, r-h...@r-project.org
mohsin ali wrote:
> Hi Sir
>
>
>
> How can I change plot size, figure size and device size? The examples availble for par() function are not very helpful. Would you please give a very simple example?
>
>
Hi Mohsin,
The device size is determined by the function that starts it. For
example, the default "graphics window" is 7x7 inches (17.78x17.78 cm).
To find out what the device size is:

par("din") # in inches

The figure size is the device size less the "outer margin". This is
often the same as the device size, unless you explicitly set the outer
margins:

par(oma=...) # in lines of text
OR
par(omi=...) # in inches

To find out what the figure size is:

par("fin") # in inches

The plot size is the figure size less the margin. To find out what it is:

par("pin") # in inches
OR
par("usr") # in user units

So you could set up the three like this:

x11(width=9,height=6)
par(oma=c(1,1,1,1)) # allow space for one line of text on each side
par(mar=c(0,4,3,2)) # allow this much space for lines of text inside the
figure

Jim

Stefan Grosse

unread,
Aug 17, 2009, 8:04:37 AM8/17/09
to mohsin ali, r-h...@r-project.org
On Mon, 17 Aug 2009 05:54:18 +0000 mohsin ali <ali.m...@hotmail.com>
wrote:

MA> How can I change plot size, figure size and device size? The
MA> examples availble for par() function are not very helpful. Would
MA> you please give a very simple example?

It would be easier if you would tell what exactly you want to do. I
believe the easiest way is not par but the options of the device. For
example:

png("myplot.png",width=400,height=400)
plot(...)
dev.off()

vs.:

png("myplot.png",width=800,height=400)
plot(...)
dev.off()

hth
Stefan

Stefan Grosse

unread,
Aug 18, 2009, 3:11:06 AM8/18/09
to mohsin ali, r-h...@r-project.org
On Mon, 17 Aug 2009 16:47:23 +0000 mohsin ali <ali.m...@hotmail.com>
wrote:

MA> I also found this way much easier. But when to have figure on MS
MA> Word, it is copied and then pasted on MS word then minor pixels
MA> appears. How to get a clear figure?

Use another device. I personally use *.eps which can be obtained by:

postscript("myplot.eps",width=8,height=8,paper="special",horizontal=F)
plot(...)
dev.off()

note that width and height are different here to the png device where
the size is in points.

You can use this in word 200x but note that the plot will look ugly on
the screen. It will look great when you print it with a postscript
printer or when you produce a pdf out of that word file.

Look also here on how you could produce wmf/emf files:
http://wiki.r-project.org/rwiki/doku.php?id=tips:graphics-misc:export#exporting_r_graphs_-_cross-platform_solutions

Reply all
Reply to author
Forward
0 new messages