Michal Gallay | 2 May 12:45 2007
Picon

no plots into viewport

Dear R Users,

could anyone help me and explain why no plot with 'plot'function is plotted 
in the viewport, but as a single plot on the next page?

grid.text() works, but neither xyplot() nor plot() do.

library(graphics)
library(grid)
library(lattice)

top.vp <- viewport(layout = grid.layout(1,2))
vp.plot1 <- viewport(layout.pos.col=1,layout.pos.row=1, name="vp.plot1")
vp.plot2 <- viewport(layout.pos.col=2,layout.pos.row=1, name="vp.plot2")
splot <- vpTree(top.vp, vpList(vp.plot1, vp.plot2))

pushViewport(splot)
seekViewport("vp.plot1")
grid.text("plot1 should be here")
plot <- xyplot(1:10~1:10)
print(plot)

Thank you very much for advice.

Michal

--

-- 
Michal Gallay

Postgraduate Research Student
(Continue reading)

Roger Bivand | 2 May 14:01 2007
Picon

Re: no plots into viewport

On 2 May 2007, Michal Gallay wrote:

> Dear R Users,
> 
> could anyone help me and explain why no plot with 'plot'function is plotted 
> in the viewport, but as a single plot on the next page?
> 
> grid.text() works, but neither xyplot() nor plot() do.
> 
> library(graphics)
> library(grid)
> library(lattice)
> 
> top.vp <- viewport(layout = grid.layout(1,2))
> vp.plot1 <- viewport(layout.pos.col=1,layout.pos.row=1, name="vp.plot1")
> vp.plot2 <- viewport(layout.pos.col=2,layout.pos.row=1, name="vp.plot2")
> splot <- vpTree(top.vp, vpList(vp.plot1, vp.plot2))
> 
> pushViewport(splot)
> seekViewport("vp.plot1")
> grid.text("plot1 should be here")
> plot <- xyplot(1:10~1:10)
> print(plot)
> 
> Thank you very much for advice.

Since the density of experienced lattice graphics users on this list 
doesn't seem to be high - you didn't get any reply to your similarly 
careful question a couple of days ago - perhaps you should ask on the R 
help list? I see that:
(Continue reading)

Gabor Grothendieck | 2 May 14:32 2007
Picon

Re: no plots into viewport

Missed this but just noticed it when Roger replied.  Try:

print(plot, newpage = FALSE)

On 02 May 2007 11:45:07 +0100, Michal Gallay
<mgallay01 <at> queens-belfast.ac.uk> wrote:
> Dear R Users,
>
> could anyone help me and explain why no plot with 'plot'function is plotted
> in the viewport, but as a single plot on the next page?
>
> grid.text() works, but neither xyplot() nor plot() do.
>
> library(graphics)
> library(grid)
> library(lattice)
>
> top.vp <- viewport(layout = grid.layout(1,2))
> vp.plot1 <- viewport(layout.pos.col=1,layout.pos.row=1, name="vp.plot1")
> vp.plot2 <- viewport(layout.pos.col=2,layout.pos.row=1, name="vp.plot2")
> splot <- vpTree(top.vp, vpList(vp.plot1, vp.plot2))
>
> pushViewport(splot)
> seekViewport("vp.plot1")
> grid.text("plot1 should be here")
> plot <- xyplot(1:10~1:10)
> print(plot)
>
> Thank you very much for advice.
>
(Continue reading)

Michal Gallay | 2 May 20:54 2007
Picon

Re: no plots into viewport

On May 2 2007, Roger Bivand wrote:

> On 2 May 2007, Michal Gallay wrote:
> 
> > Dear R Users,
> > 
> > could anyone help me and explain why no plot with 'plot'function is 
> > plotted in the viewport, but as a single plot on the next page?
> > 
> > grid.text() works, but neither xyplot() nor plot() do.
> > 
> > library(graphics)
> > library(grid)
> > library(lattice)
> > 
> > top.vp <- viewport(layout = grid.layout(1,2))
> > vp.plot1 <- viewport(layout.pos.col=1,layout.pos.row=1, name="vp.plot1")
> > vp.plot2 <- viewport(layout.pos.col=2,layout.pos.row=1, name="vp.plot2")
> > splot <- vpTree(top.vp, vpList(vp.plot1, vp.plot2))
> > 
> > pushViewport(splot)
> > seekViewport("vp.plot1")
> > grid.text("plot1 should be here")
> > plot <- xyplot(1:10~1:10)
> > print(plot)
> > 
> > Thank you very much for advice.
> 
> Since the density of experienced lattice graphics users on this list 
> doesn't seem to be high - you didn't get any reply to your similarly 
(Continue reading)

Edzer J. Pebesma | 3 May 10:58 2007
Picon

Re: Several gstat variograms on a single page

Michal,

I think (and hope for you) it is not necessary to search the solution at 
the level of grid. The plot function for variograms in package gstat is 
a rather (?) thin wrapper around xyplot, so if you carefully read how to 
control the main and sub arguments of ?xyplot, then you're done:

library(gstat)
data(meuse)
coordinates(meuse)=~x+y
v = variogram(log(zinc)~1,meuse)
v.pl = plot(v, main="log-zinc",sub=list(label = "xx", cex=.5))

Next you can print the v.pl etc. objects side by side using print(v.pl, 
more = TRUE) etc.
--
Edzer

Michal Gallay wrote:
> Dear R Users,
>
> I'd like to ask you for help. I am R beginner, tackling R for about three 
> months. I'd like to produce variograms with 0, 1st, 2nd order detrending 
> for 30 ascii grid files containing elevation data.
>
> I've got problem with a simple thing but as it seems to me not as easy one 
> as I thought. I hope I just can't see because of my eyes.
>
> I'd like to plot three gstat variograms in one row on one page, to give 
> them a main title (just single one for all three of the plots), and for 
(Continue reading)

Edzer J. Pebesma | 3 May 11:06 2007
Picon

Re: Simulating raster or spatialgriddataframe images

Andrew,

If you want to simulate particular random fields that are Gaussian or 
binary, described by a second order properties (mean, variogram), then 
you may want to look into the simulation capabilities of packages 
RandomFields or gstat. If you want to simulate objects (circles, 
ellipses, stars), then you may need to do some point-in-polygon stuff, 
which is fairly easy to automate. Perhaps using overlay (in package sp) 
if you have the object as a SpatialPolygons[DataFrame] object.

Hth,
--
Edzer

Andrew Niccolai wrote:
> Greetings,
>
> At the risk of being ridiculed for such a general question, can anyone offer
> suggestions or decent code to simulate grid images with specific patterns?
> I have been reading R Graphics and I am not sure if a grob will suffice, but
> I would like to create a "controlled" circular or rectangular image in which
> I can insert a star pattern or a pattern of high valued clumps evenly
> distributed around the image.  I am interested in creating these controlled
> or simulated images in order to better understand the ability of gstar and
> local moran's I statistics in discriminating among image objects with
> different internal patterns but that share similar overall averages and
> standard deviations.  Can anyone suggest code or techniques inside of R that
> will allow me to create a series of SGDF objects that have a specific set of
> internal patterns associated with them.
>
(Continue reading)

Michal Gallay | 4 May 00:05 2007
Picon

Re: Several gstat variograms on a single page

Thank you Edzer,

you're right, the layout I wanted to get can be produced just using simple 
'graphics' functions. I've already 'discovered' how to do it.

At this stage, I find Lattice and Grid graphics too complex. The biggest 
problem is to understand how particular features of a lattice/grid plot are 
controlled. However, step by step, I am getting there.

Best wishes,

Michal

On May 3 2007, Edzer J. Pebesma wrote:

> Michal,
> 
> I think (and hope for you) it is not necessary to search the solution at 
> the level of grid. The plot function for variograms in package gstat is 
> a rather (?) thin wrapper around xyplot, so if you carefully read how to 
> control the main and sub arguments of ?xyplot, then you're done:
> 
> library(gstat)
> data(meuse)
> coordinates(meuse)=~x+y
> v = variogram(log(zinc)~1,meuse)
> v.pl = plot(v, main="log-zinc",sub=list(label = "xx", cex=.5))
> 
> Next you can print the v.pl etc. objects side by side using print(v.pl, 
> more = TRUE) etc.
(Continue reading)

Tom Boonen | 4 May 18:40 2007
Picon

merge vector into a SpatialPolygonsDataFrame

Hi,

I am a newbie to the spatial stats (but know R). I would like to plot
a map where the colors for the various polygons are given by the value
of a vector.

# So I do my vector
# vector with 437 datapoints for 437 polygons
x <- 1:437

I# Then I read in my shapefile which works fine:
myshp   <- readShapePoly("cd99_109.shp")

> summary(myshp)
Object of class SpatialPolygonsDataFrame
Coordinates:
          min       max
r1 -179.14734 179.77847
r2   17.88481  71.35256
Is projected: NA
proj4string : [NA]
Data attributes:
     STATE           CD      LSAD          NAME        GEOCODE
                               LSAD_TRANS
 06     : 53   01     : 43   C1:  7   1      : 43   0101   :  1
Congressional District                   :428
 48     : 32   02     : 43   C2:428   2      : 43   0102   :  1
Congressional District (at Large)        :  7
 36     : 29   03     : 38   C3:  1   3      : 38   0103   :  1
Delegate District (at Large)             :  1
(Continue reading)

Roger Bivand | 4 May 21:31 2007
Picon

Re: merge vector into a SpatialPolygonsDataFrame

On Fri, 4 May 2007, Tom Boonen wrote:

> Hi,
> 
> I am a newbie to the spatial stats (but know R). I would like to plot
> a map where the colors for the various polygons are given by the value
> of a vector.
> 
> # So I do my vector
> # vector with 437 datapoints for 437 polygons
> x <- 1:437
> 
> I# Then I read in my shapefile which works fine:
> myshp   <- readShapePoly("cd99_109.shp")
> 
> > summary(myshp)
> Object of class SpatialPolygonsDataFrame
> Coordinates:
>           min       max
> r1 -179.14734 179.77847
> r2   17.88481  71.35256
> Is projected: NA
> proj4string : [NA]
> Data attributes:
>      STATE           CD      LSAD          NAME        GEOCODE
>                                LSAD_TRANS
>  06     : 53   01     : 43   C1:  7   1      : 43   0101   :  1
> Congressional District                   :428
>  48     : 32   02     : 43   C2:428   2      : 43   0102   :  1
> Congressional District (at Large)        :  7
(Continue reading)

Steven J. Pierce | 4 May 23:44 2007
Picon

Re: Several gstat variograms on a single page

Michal,

The best source I've found for understanding how to work with the graphics
capabilities in R is a recently published book:

Murrell, Paul (2006). R Graphics. Boca Raton, FL: Chapman & Hall/CRC. 
http://www.amazon.com/Graphics-Computer-Science-Data-Analysis/dp/158488486X/
ref=pd_bbs_sr_1/103-4142948-9887845?ie=UTF8&s=books&qid=1178315019&sr=8-1

Steven J. Pierce, M.S.
Doctoral Student in Ecological/Community Psychology
Department of Psychology
Michigan State University
240B Psychology Building
East Lansing, MI 48824-1116

E-mail: pierces1 <at> msu.edu
Web: http://www.psychology.msu.edu/eco/

-----Original Message-----
From: Michal Gallay [mailto:mgallay01 <at> Queens-Belfast.AC.UK] 
Sent: Thursday, May 03, 2007 6:06 PM
To: Edzer J. Pebesma
Cc: R geo forum; Michal Gallay
Subject: Re: [R-sig-Geo] Several gstat variograms on a single page

Thank you Edzer,

you're right, the layout I wanted to get can be produced just using simple
'graphics' functions. I've already 'discovered' how to do it.
(Continue reading)


Gmane