[R] Problem with plotting size/location on variation of star/segment plot

Shelby Berkowitz berkowi4 at msu.edu
Sat Mar 5 17:42:02 CET 2005


Dear R gurus,

I'm running into a problem with some modified segment plots I've coded
using stars().  What I am trying to do is superimpose two series of data
along with radial axes markers in a 2x2 graphics frame.  This is working
fine now, except for the hitch: my plots overfill the frame and are not
centered within it (on my runs they always end up looking like they've
been budged up and to the left).  They're also a little warped-looking
(more oval than perfectly round).

- I don't think this is a problem with my par() settings, as I've
checked them out and they don't look suspicious.  Also, I've tested
generating other plots (e.g., dummy histograms) on the same device and
they fit perfectly.  It's also not a problem with fitting stars() plots
into a par(mfrow=c(2,2) frame, as I get the same offset/overflow when I
run just one plot on a mfrow=c(1,1) frame.
- I don't think it's a problem with the windows graphics device, as I
tried plotting to other devices (e.g., postscript) and get the same
results.
- Thus, I'm pretty sure this comes down to something funky with the way
I'm using stars().  My runs of examples from stars() fit just as they
should inside their graphics frames, but as far as I can see, the
individual calls to stars() below don't look materially different from
the ones in the examples.

At this point, I'm completely stumped.  Can someone please point me
towards what I might be doing wrong here?  Any and all advice will be
most humbly appreciated!
BTW, I'm running R 2.00 on Windows XP, all packages updated.

Example version of my code is pasted below (the loop is for example
purposes only):

##begin sample code
par(mfrow=c(2,2))
for (i in 1:4) {
	## generate sample data for plot:
	a<- sample(c(20:70)*.01,18)
	testA <-
as.data.frame(rbind(a,a+((1-a)*sample(c(1:10)*.1,18,replace=T))))
	## open new plot space
	plot.new()
	## plot data series:
	stars(testA[2,], locations=0:1,full = TRUE, scale = F,
draw.segments=TRUE, add=TRUE,col.segments=heatshades[7])
	stars(testA[1,], locations=0:1,full = TRUE, scale = F,
draw.segments=TRUE, add=TRUE,col.segments=heatshades[3])
	majgrid <- matrix(rep((c(1:10)*.1),ncol(testA)),nrow=10,byrow=F)
	## generate and plot radar grid:
	mingrid <-
matrix(rep((c(1:10)*.1-.05),ncol(testA)),nrow=10,byrow=F)
	stars(majgrid, locations=0:1, scale=F, draw.segments = TRUE,
add=T, lty=1, col.segments=0)
	stars(mingrid, locations=0:1, scale=F, draw.segments = TRUE,
add=T, lty=2, col.segments=0)}
par(mfrow=c(1,1))
##end sample code

Thank you,

Shelby

===============================
Shelby L. Berkowitz
Ecological-Community Psychology
and Institute for Health Care Studies
Michigan State University
berkowi4 at msu.edu




More information about the R-help mailing list