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

From: Shelby Berkowitz <>
Date: Tue 08 Mar 2005 - 12:23:39 EST

Beautiful!!! Thanks so much, Uwe!

[Notes for anyone else stumbling across similar issues in the future: After making the change Uwe suggested, I realized a couple of things: first, the commands were redundant with add=F in place. Second, I was still scratching my head for a few minutes wondering why some of my plots now fit perfectly while others were still a bit too big for the frame (though not as bad as before). Then I put 2 and 2 together based on a hint in Uwe's message: the first plot command in the series was driving the dimension calculations. So...plots that had one or more data points at the full radius of my post-plotted axes ended up fine, others ended up too big once the final gridlines were added. The solution of course was to make the first stars() command a plot of the major-gridline axis with invisible lines. Revised code follows.]

par(mfrow=c(2,2), mar=c(1,0,1,0),oma=c(2,2,2,2)) ## code segment for each separate radar chart within frame majgrid <- matrix(rep((c(1:10)*.1),ncol(DF)),nrow=10,byrow=F) mingrid <- matrix(rep((c(1:10)*.1-.05),ncol(DF)),nrow=10,byrow=F) stars(majgrid, locations = 0:1, scale=F, draw.segments = TRUE, add=FALSE, lty=0, col.segments=0,main="Plot Title") stars(DF[seriesindex1,], locations=0:1,full = TRUE, scale = F, draw.segments=TRUE, add=TRUE,col.segments=heatshades[7]) stars(DF[seriesindex2,], locations=0:1,full = TRUE, scale = F, draw.segments=TRUE, add=TRUE,col.segments=heatshades[3])

stars(majgrid, locations = 0:1, scale=F, draw.segments = TRUE, add=T,
lty=1, col.segments=0,lwd=1.5)
stars(mingrid, locations = 0:1, scale=F, draw.segments = TRUE, add=T,
lty=2, col.segments=0,lwd=1)

###rinse and repeat as needed



>-----Original Message-----
>From: Uwe Ligges []
>Sent: Saturday, March 05, 2005 1:49 PM
>To: Shelby Berkowitz

>Subject: Re: [R] Problem with plotting size/location on
>variation of star/segment plot
>Shelby Berkowitz wrote:
>> 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
>> 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 <-
>> ## open new plot space
>> ## plot data series:
>> stars(testA[2,], locations=0:1,full = TRUE, scale = F,
>> draw.segments=TRUE, add=TRUE,col.segments=heatshades[7])
>Well, since you have neither called plot.window() nor stars() with
>"add=FALSE"), the dimensions have not been set up correctly.
>In the first call above, simply say add = FALSE.
>Uwe Ligges
>> 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
>> mailing list PLEASE do read the posting guide! Received on Tue Mar 08 12:29:03 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:30:41 EST