[R] R units of margins, text and points in a figure

Gygli, Gudrun gudrun.gygli at wur.nl
Tue Nov 10 09:15:43 CET 2015


Dear R-help,


I am trying to plot some data in a plot where I leave a big margin free to add other information, namely text and points.

I am now struggling with keeping the size of the margin, text and points in a fixed ratio. I want this so that the layout of the figure does not change every time I plot new data.

I have:

a<-8
counter<-1
spacing<-a/(3*a)
adding<-a/(3*a)
start<-a*(a/3)

alphabet<-c("A","A","A","A","A","A","A","A")
x<-c(1,2,3,4,5,6,7,8)
y<-c(10,20,30,40,50,60,70,80)
png(file="TESTING.png", units="in", width=a, height=a, res=a*100)
par(xpd=NA,mar=c(0,0,0,0),oma=c(0,0,0,(3*a))) #bottom, left,top, right

plot.new()
plot(x,y)
points(pch=20,10, 10, cex=5)
text(10,10, alphabet, cex=5, col="blue")

What I do not understand is why the size of the point and the text is not the same and why the margin can be "bigger" than the width of the figure.

BASICALLY, the units of the margins, the points and the text are not the same...

What I need is a way to make the size of the point and text AND the margin independent of the data I plot so that the figure always looks the same although there is more data in it in some cases (for example 10 or 20 points with text in the margin).

This could be done by setting the units of points, text and margin to inches so that a is the same for all of them... Or to know the ratio between the different units used by R for margin, points and text...

Any ideas on how to solve that?

Please let me know if clarifications are needed!


Gudrun







Gudrun Gygli, MSc

PhD candidate

Wageningen University
Laboratory of Biochemistry
Dreijenlaan 3
6703 HA Wageningen
The Netherlands

Phone  31 317483387
e-mail: gudrun.gygli at wur.nl

- - - - - - - - - - - - - - - - - -

Project information: http://www.wageningenur.nl/en/show/Bioinformatics-structural-biology-and-molecular-modeling-of-Vanillyl-Alcohol-Oxidases-VAOs.htm



More information about the R-help mailing list