Skip to content

xyplot (lattice), strip.default

7 messages · Vladimir Eremeev, Brian Ripley, Renaud Lancelot +4 more

#
Dear r-help,

  I've got data of the following structure
1979  93.428747  0
1979  87.298608  20
1979  78.506340  40
...
1979  45.567890  340
1980  60.815289  0
1980  49.630904  20
1980  24.981362  40
...

The first column is year and the last one is the longitude.
I need a set of graphs showing the dependence of the middle value on
the longitude, for each year, situated one blow the other.
I.e.
1979: --...---```--``--..
1980: ...--``../``\...---
...
etc.

Here characters ---...---``` denote the curve.
The middle value is on the vertical axis
and the latitude is on the horizontal axis of each graph.

To do this I use xyplot function from the Lattice package:

xyplot(ac15$"value"~ac15$lon|year,data=ac15,
       type="l",
       layout=c(1,24),
       xlab="Longitude",
       as.table=TRUE,
       bg="white"
      );

But I have some problems using it.

Questions:

1. How to make xyplot to draw the year value in the strip above each
graph instead of writing the word 'year'?

2. I'd like to produce a .png file with graphs without drawing them on
the screen.

I try:
png(filename = "Rplot.png", width = 480, height = 1024, pointsize = 12,
         bg = "white");

trellis.device(device=getOption("png"),
               color = FALSE,
               bg = "white" );

xyplot.... [see above]

But I get the error message:

Error in trellis.device(device = getOption("png"), color = FALSE, bg = "white") :
        couldn't find function "device.call"

Where's the problem?

I use R 1.7.0 and Windows NT 4.0 workstation.

Thank you for attention and help!
#
On Tue, 6 May 2003, Wladimir Eremeev wrote:

            
Thare is no option "png".  Look at the help for trellis.device to see what 
you should be using as a `device' argument: it even lists how to use the 
png() device.

  
    
#
Wladimir Eremeev wrote:
Look at ?strip.default and try style = 4, or style = 5:

fooData <- data.frame(
     year = factor(rep(2001:2010, each = 20)),
     y = rnorm(200),
     x = rep(1:20, time = 10))

library(lattice)

trellis.device(bg = "white")
xyplot(y ~  x | year, data = fooData,
        type = "l",
        layout = c(1, 10),
        xlab = "Longitude",
        as.table = TRUE,
        strip = function(...) strip.default(style = 5,...)
        )
Look at ?trellis.device:

trellis.device(bg = "white",
                device = "png",
                filename = "d:/analyses/fig1.png")
xyplot(y ~  x | year, data = fooData,
        type = "l",
        layout = c(1, 10),
        xlab = "Longitude",
        as.table = TRUE,
        strip = function(...) strip.default(style = 5,...)
        )
dev.off()

Best,

Renaud

  
    
#
Is there any neat way of producing character-based "dumb" plots in R
rather than the ordinary very good-looking graphics? It would at times be
both easy and sufficient to include such crude graphs in HTML pages rather
or similar.

--robert
#
Robert Lundqvist wrote:
You could always use Splus version 3. It had a crt() and a printer() 
graphics device, which produced ascii plots. I'd paste an example here 
but doubtless the widespread use of proportional fonts would make it 
look like what we used to call 'line noise' back in the old days.

  It can do simple line and point plots, but dont expect too much:

 > printer()
 > image(matrix(runif(100),10,10))
Error in image.default(matrix(runif(100), 10, 10)): Inactive device or
         unimplemented device primitive
Dumped
Error in image
 >

  For those of you with proportional fonts, here's 10 data points with a 
fitted linear model:

      25.........................................
        .                                    *.
        .                                  ...
     20..                               ...
        .                            *.. *
        .                         ...
     15..                    * ...
  y     .                *  ...  *
        .            *   ...
     10..             ...
        .        * ...
        .       ...
      5..*   ...
        . ...
        ..   *
        ........................................
             2       4       6       8       10

                           x


  Since R is open source, if you really really want this, you could 
either write a 'crt()' graphics device for R, or if you really really 
really want it, pay someone to do it!

Baz
#
How about:

Dat <- array(1:10, dim=c(10,2))
dimnames(Dat) <- list(NULL, c("x", "y"))
Crt <- array(" ", dim=c(10,10))
Crt[Dat] <- "*"
for(i in 1:10)
	cat(Crt[,11-i], "\n")

This worked in both R 1.6.2 and S-Plus 6.1 under Windows 2000.
hth.  spencer graves
Robert Lundqvist wrote:
#
On Tuesday 06 May 2003 03:23 am, Wladimir Eremeev wrote:
The simplest way would be to supply year as a factor, I think.

xyplot(value ~ lon | factor(year), data=ac15,
       type="l",
       layout=c(1,24),
       xlab="Longitude",
       as.table=TRUE)

The bg = "white" would have no effect here, as others have already pointed 
out.

Deepayan