[R] Plotting multiple xyplots in same page

2013-02-13 Thread Lisa Daniel
Dear Rhelp,

I would like to have 6 xyplots in the same page.  Similar to (par(mfrow=c(3,3))
Found this example on the R archives.
library(lattice)
trellis.par.set(theme = col.whitebg())
xy <- xyplot(decrease ~ treatment, OrchardSprays,
  groups = rowpos, type = "a",
  auto.key = list(x = 0.2, y = 0.9,
    cex = 0.75, points = FALSE, lines = TRUE))

print(xy, pos = c(0.0, 0.0, 0.5, 0.5), more = TRUE)
print(xy, pos = c(0.0, 0.5, 0.5, 1.0), more = TRUE)
print(xy, pos = c(0.5, 0.0, 1.0, 0.5), more = TRUE)
print(xy, pos = c(0.5, 0.5, 1.0, 1.0), more = FALSE)




When I changed the print() to:

 print(xy, pos=c(0.0,0.0,0.33,0.33),more = TRUE),
the figure was not looking good.

Also, is it possible to assign A, B, C,D, etc for each figure. 



a<- rnorm(1000,0,1) 
b<- rnorm(1000,0,2) 
c<- rnorm(1000,0,3) 
d<- rnorm(1000,0,4) 
par(mfrow=c(2,2)) 
hist(a,main="") 
title(main="A",adj=0) 
hist(b,main="") 
title(main="B",adj=0) 
hist(c,main="") 
title(main="C",adj=0) 
hist(d,main="") 
title(main="D",adj=0)


I tried this to xyplot, but it was not working.

Please help me.  

Many thanks in advance,
Lisa.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Plotting multiple xyplots in same page

2013-02-13 Thread Lisa Daniel
Dear Rhelp,

I was able to plot 6 figures in one page.  I do need help in reducing the space 
between the title and the plot and assigning A,B,C,D,E,F to each figure
library(lattice)
trellis.par.set(theme = col.whitebg())
xy <- xyplot(decrease ~ treatment, OrchardSprays,
        main="Some plot",
  groups = rowpos, type = "a",
  auto.key = list(x = 0.2, y = 0.9,
    cex = 0.52, points = FALSE, lines = TRUE))


print(xy, pos = c(0.0, 0.5, 0.33, 1.0), more = TRUE)
print(xy, pos = c(0.33, 0.5, 0.66, 1.0), more = TRUE)
print(xy, pos = c(0.66, 0.5, 0.99, 1.0), more = TRUE)
print(xy, pos = c(0.0, 0.0, 0.33, 0.5), more = TRUE)
print(xy, pos = c(0.33, 0.0, 0.66, 0.5), more = TRUE)
print(xy, pos = c(0.66, 0.0, 0.99, 0.5), more = FALSE)

Thanks in advance,
Lisa



- Original Message -
From: Lisa Daniel 
To: "r-help@r-project.org" 
Cc: 
Sent: Wednesday, February 13, 2013 5:28 PM
Subject: Plotting multiple xyplots in same page

Dear Rhelp,

I would like to have 6 xyplots in the same page.  Similar to (par(mfrow=c(3,3))
Found this example on the R archives.
library(lattice)
trellis.par.set(theme = col.whitebg())
xy <- xyplot(decrease ~ treatment, OrchardSprays,
  groups = rowpos, type = "a",
  auto.key = list(x = 0.2, y = 0.9,
    cex = 0.75, points = FALSE, lines = TRUE))

print(xy, pos = c(0.0, 0.0, 0.5, 0.5), more = TRUE)
print(xy, pos = c(0.0, 0.5, 0.5, 1.0), more = TRUE)
print(xy, pos = c(0.5, 0.0, 1.0, 0.5), more = TRUE)
print(xy, pos = c(0.5, 0.5, 1.0, 1.0), more = FALSE)




When I changed the print() to:

 print(xy, pos=c(0.0,0.0,0.33,0.33),more = TRUE),
the figure was not looking good.

Also, is it possible to assign A, B, C,D, etc for each figure. 



a<- rnorm(1000,0,1) 
b<- rnorm(1000,0,2) 
c<- rnorm(1000,0,3) 
d<- rnorm(1000,0,4) 
par(mfrow=c(2,2)) 
hist(a,main="") 
title(main="A",adj=0) 
hist(b,main="") 
title(main="B",adj=0) 
hist(c,main="") 
title(main="C",adj=0) 
hist(d,main="") 
title(main="D",adj=0)


I tried this to xyplot, but it was not working.

Please help me.  

Many thanks in advance,
Lisa.


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Plotting multiple xyplots in same page

2013-02-13 Thread Lisa Daniel
Dear Duncan,

Thank you.  It helped a lot.
I was able to get it correct though I couldn't get it working under 
simpleTheme() (for publication purpose).

#this gave me the correct format.
library(grid)
library(lattice)
xy <-xyplot(decrease ~ treatment, OrchardSprays,
    main= "Some plot",
    groups = rowpos, type = "a",
    page = function(n){
 grid.text(LETTERS[j],
 y = 0.95,
 x = 0.15,
 default.units = "npc",
 just = c("left"),
 gp = gpar(fontsize = 12,fontface="bold") )
   },
    par.settings = list(
 layout.heights = list(main = 1.2,
   sub  = 0,
   axis.top = 0.2,
   top.padding  = 0.1,
   bottom.padding = 0) ),
    auto.key = list(x = 0.2, y = 0.9,
    cex = 0.75, points = FALSE, lines = TRUE)) 
#pdf("trial.pdf",width=12)
#jpeg("trial.jpeg",quality=100,width=680,height=480)
j=1
print(xy, pos = c(0.0, 0.5, 0.33, 1.0), more = TRUE)
j=j+1
print(xy, pos = c(0.33, 0.5, 0.66, 1.0), more = TRUE)
j=j+1
print(xy, pos = c(0.66, 0.5, 0.99, 1.0), more = TRUE)
j=j+1
print(xy, pos = c(0.0, 0.0, 0.33, 0.5), more = TRUE)
j=j+1
print(xy, pos = c(0.33, 0.0, 0.66, 0.5), more = TRUE)
j=j+1
print(xy, pos = c(0.66, 0.0, 0.99, 0.5), more = FALSE)
#dev.off()


# I tried the same with simpleTheme(), but I am not getting it correct, (the 
lines are colored):

pset <- simpleTheme(lty = 1:8, col="black",lwd=2)  
xy <-xyplot(decrease ~ treatment, OrchardSprays,
    main= "Some plot",
    groups = rowpos, type = "a",
    page = function(n){
 grid.text(LETTERS[j],
 y = 0.95,
 x = 0.15,
 default.units = "npc",
 just = c("left"),
 gp = gpar(fontsize = 12,fontface="bold") )
   },
    par.settings = list(pset,
 layout.heights = list(main = 1.2,
   sub  = 0,
   axis.top = 0.2,
   top.padding  = 0.1,
   bottom.padding = 0) ),
    auto.key = list(x = 0.2, y = 0.9,
    cex = 0.75, points = FALSE, lines = TRUE)) 
j=1
print(xy, pos = c(0.0, 0.5, 0.33, 1.0), more = TRUE)
j=j+1
print(xy, pos = c(0.33, 0.5, 0.66, 1.0), more = TRUE)
j=j+1
print(xy, pos = c(0.66, 0.5, 0.99, 1.0), more = TRUE)
j=j+1
print(xy, pos = c(0.0, 0.0, 0.33, 0.5), more = TRUE)
j=j+1
print(xy, pos = c(0.33, 0.0, 0.66, 0.5), more = TRUE)
j=j+1
print(xy, pos = c(0.66, 0.0, 0.99, 0.5), more = FALSE)


#the output from the below code is B&W, but space between title and figure not 
corrected

pset <- simpleTheme(lty = 1:8, col="black",lwd=2)  
xy <-xyplot(decrease ~ treatment, OrchardSprays,
    main= "Some plot",
    groups = rowpos, type = "a",
    page = function(n){
 grid.text(LETTERS[j],
 y = 0.95,
 x = 0.15,
 default.units = "npc",
 just = c("left"),
 gp = gpar(fontsize = 12,fontface="bold") )
   },
    par.settings = pset,
    auto.key = list(x = 0.2, y = 0.9,
    cex = 0.75, points = FALSE, lines = TRUE)) 

j=1
print(xy, pos = c(0.0, 0.5, 0.33, 1.0), more = TRUE)
j=j+1
print(xy, pos = c(0.33, 0.5, 0.66, 1.0), more = TRUE)
j=j+1
print(xy, pos = c(0.66, 0.5, 0.99, 1.0), more = TRUE)
j=j+1
print(xy, pos = c(0.0, 0.0, 0.33, 0.5), more = TRUE)
j=j+1
print(xy, pos = c(0.33, 0.0, 0.66, 0.5), more = TRUE)
j=j+1
print(xy, pos = c(0.66, 0.0, 0.99, 0.5), more = FALSE)


Also, I would like to create a main title for the first row and second row of 
figures.
Many thanks in advance,
Lisa


- Original Message -
From: Duncan Mackay 
To: Lisa Daniel ; r-help-r-project.org 

Cc: 
Sent: Wednesday, February 13, 2013 7:53 PM
Subject: Re: [R] Plotting multiple xyplots in same page

Hi Lisa

have a look at par.settings in ?xyplot

trellis.par.get() shows the settings

trellis.par.get()[[27]]
$left
$left$tck
[1] 1

$left$pad1
[1] 1

$left$pad2
[1] 1


$top
$top$tck
[1] 1

$top$pad1
[1] 1

$top$pad2
[1] 1


$right
$right$tck
[1] 1

$right$pad1
[1] 1

$right$pad2
[1] 1


$bottom
$bottom$tck
[1] 1

$bottom$pad1
[1] 1

$bottom$pad2
[1] 1

as an example:

par.settings = list(
layout.heights = list(main = 0,
                       sub  = 0,
                       axis.top = 0.2,
                       top.padding  = 0,
                       bottom.padding = 0)    )

HTH

Duncan

Duncan Mackay
Department of Agronomy and Soil Science
University of New

Re: [R] Plotting multiple xyplots in same page

2013-02-13 Thread Lisa Daniel
Dear Duncan and Pascal,
Thank you for the response.

Duncan: 

I was able to fix the space between title and figure.  I would also like to  
have separate main titles for each row of figures in addition to the individual 
titles.

xy <-xyplot(decrease ~ treatment, OrchardSprays,
    main= "Some plot",
    groups = rowpos, type = "a",
    page = function(n){
 grid.text(LETTERS[j],
 y = 0.95,
 x = 0.15,
 default.units = "npc",
 just = c("left"),
 gp = gpar(fontsize = 12,fontface="bold") )
   },
    par.settings = c(simpleTheme(lty=1:8, 
col="black",lwd=2),list(layout.heights = list(main = 1.2,
   sub  = 0,
   axis.top = 0.2,
   top.padding  = 0.1,
   bottom.padding = 0)) ),
    auto.key = list(x = 0.2, y = 0.9,
    cex = 0.75, points = FALSE, lines = TRUE)) 
j=1
print(xy, pos = c(0.0, 0.5, 0.33, 1.0), more = TRUE)
j=j+1
print(xy, pos = c(0.33, 0.5, 0.66, 1.0), more = TRUE)
j=j+1
print(xy, pos = c(0.66, 0.5, 0.99, 1.0), more = TRUE)
j=j+1
print(xy, pos = c(0.0, 0.0, 0.33, 0.5), more = TRUE)
j=j+1
print(xy, pos = c(0.33, 0.0, 0.66, 0.5), more = TRUE)
j=j+1
print(xy, pos = c(0.66, 0.0, 0.99, 0.5), more = FALSE)

Pascal:
I would prefer not to use panels as this is for publication purpose.  


Many thanks,
Lisa





----- Original Message -
From: Duncan Mackay 
To: Lisa Daniel ; r-help-r-project.org 

Cc: 
Sent: Wednesday, February 13, 2013 7:53 PM
Subject: Re: [R] Plotting multiple xyplots in same page

Hi Lisa

have a look at par.settings in ?xyplot

trellis.par.get() shows the settings

trellis.par.get()[[27]]
$left
$left$tck
[1] 1

$left$pad1
[1] 1

$left$pad2
[1] 1


$top
$top$tck
[1] 1

$top$pad1
[1] 1

$top$pad2
[1] 1


$right
$right$tck
[1] 1

$right$pad1
[1] 1

$right$pad2
[1] 1


$bottom
$bottom$tck
[1] 1

$bottom$pad1
[1] 1

$bottom$pad2
[1] 1

as an example:

par.settings = list(
layout.heights = list(main = 0,
                       sub  = 0,
                       axis.top = 0.2,
                       top.padding  = 0,
                       bottom.padding = 0)    )

HTH

Duncan

Duncan Mackay
Department of Agronomy and Soil Science
University of New England
Armidale NSW 2351
Email: home: mac...@northnet.com.au




At 09:10 14/02/2013, you wrote:
>Dear Rhelp,
>
>I was able to plot 6 figures in one page.  I do need help in 
>reducing the space between the title and the plot and assigning 
>A,B,C,D,E,F to each figure
>library(lattice)
>trellis.par.set(theme = col.whitebg())
>xy <- xyplot(decrease ~ treatment, OrchardSprays,
>         main="Some plot",
>               groups = rowpos, type = "a",
>               auto.key = list(x = 0.2, y = 0.9,
>                 cex = 0.52, points = FALSE, lines = TRUE))
>
>
>print(xy, pos = c(0.0, 0.5, 0.33, 1.0), more = TRUE)
>print(xy, pos = c(0.33, 0.5, 0.66, 1.0), more = TRUE)
>print(xy, pos = c(0.66, 0.5, 0.99, 1.0), more = TRUE)
>print(xy, pos = c(0.0, 0.0, 0.33, 0.5), more = TRUE)
>print(xy, pos = c(0.33, 0.0, 0.66, 0.5), more = TRUE)
>print(xy, pos = c(0.66, 0.0, 0.99, 0.5), more = FALSE)
>
>Thanks in advance,
>Lisa
>
>
>
>- Original Message -
>From: Lisa Daniel 
>To: "r-help@r-project.org" 
>Cc:
>Sent: Wednesday, February 13, 2013 5:28 PM
>Subject: Plotting multiple xyplots in same page
>
>Dear Rhelp,
>
>I would like to have 6 xyplots in the same page.  Similar to 
>(par(mfrow=c(3,3))
>Found this example on the R archives.
>library(lattice)
>trellis.par.set(theme = col.whitebg())
>xy <- xyplot(decrease ~ treatment, OrchardSprays,
>               groups = rowpos, type = "a",
>               auto.key = list(x = 0.2, y = 0.9,
>                 cex = 0.75, points = FALSE, lines = TRUE))
>
>print(xy, pos = c(0.0, 0.0, 0.5, 0.5), more = TRUE)
>print(xy, pos = c(0.0, 0.5, 0.5, 1.0), more = TRUE)
>print(xy, pos = c(0.5, 0.0, 1.0, 0.5), more = TRUE)
>print(xy, pos = c(0.5, 0.5, 1.0, 1.0), more = FALSE)
>
>
>
>
>When I changed the print() to:
>
>  print(xy, pos=c(0.0,0.0,0.33,0.33),more = TRUE),
>the figure was not looking good.
>
>Also, is it possible to assign A, B, C,D, etc for each figure.
>
>
>
>a<- rnorm(1000,0,1)
>b<- rnorm(1000,0,2)
>c<- rnorm(1000,0,3)
>d<- rnorm(1000,0,4)
>par(mfrow=c(2,2))
>hist(a,main="")
>title(main="A",adj=0)
>hist(b,main="")
>title(main="B",adj=0)
>hist(c,main="")
>title(main="C",adj=0)
>hist(d,main="")
>title(main="D",adj=0)
>
>
>I

[R] Alternate tick labels in xyplot

2013-02-14 Thread Lisa Daniel
Dear Rhelp,

I would like to get alternate tick labels for the xyplot:
library(lattice)
library(grid)

xy <-xyplot(decrease ~ treatment, OrchardSprays,
    main= "Some plot",
    groups = rowpos, type = "a",
        page = function(n){
 grid.text(LETTERS[j],
 y = 0.95,
 x = 0.15,
 default.units = "npc",
 just = c("left"),
 gp = gpar(fontsize = 12,fontface="bold") )
   },
    par.settings = c(simpleTheme(lty=1:8, 
col="black",lwd=2),list(layout.heights = list(main = 1.2,
   sub  = 0,
   axis.top = 0.2,
   top.padding  = 0.1,
   bottom.padding = 0)) ),
    auto.key = list(x = 0.2, y = 0.9,
    cex = 0.75, points = FALSE, lines = TRUE)) 
j=1
print(xy, pos = c(0.0, 0.5, 0.33, 1.0), more = TRUE)
j=j+1
print(xy, pos = c(0.33, 0.5, 0.66, 1.0), more = TRUE)
j=j+1
print(xy, pos = c(0.66, 0.5, 0.99, 1.0), more = TRUE)
j=j+1
print(xy, pos = c(0.0, 0.0, 0.33, 0.5), more = TRUE)
j=j+1
print(xy, pos = c(0.33, 0.0, 0.66, 0.5), more = TRUE)
j=j+1
print(xy, pos = c(0.66, 0.0, 0.99, 0.5), more = FALSE)


similar to the x-axis in the code below, but somehow it is not working when I 
pasted 'list(axis.components=...) in the above code:
xyplot(rnorm(12) ~ 1:12 , type="l",
scales=list(x=list(at=seq(2,12,2),labels=c(1, ' ', 3 , ' ' , 5 , ' ' ))),
par.settings=list(axis.components=list(bottom=list(tck=c(0,1) 

scales=list(x=list(at=seq(1,8,1),labels=c('A', ' ', 'C', ' ' ,'E' , ' ','G',' 
'))),

If possible, I would like a heading for each rows (justified to center) above 
the individual heading.

Please help.
Many thanks,
Lisa.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Alternate tick labels in xyplot

2013-02-14 Thread Lisa Daniel
Dear Rhelp,
I was able to solve the tick labels part.  If somebody can help me in creating 
title for each row of figures above the individual headings, it will be great.
library(grid)
library(lattice)
xy <-xyplot(decrease ~ treatment, OrchardSprays,
    main= "Some plot",
    groups = rowpos, type = "a",
    scales=list(x=list(at=seq(1,8,1),labels=c('A','','C','','E','','G',''))),
        page = function(n){
 grid.text(LETTERS[j],
 y = 0.95,
 x = 0.15,
 default.units = "npc",
 just = c("left"),
 gp = gpar(fontsize = 12,fontface="bold") )
   },
    par.settings = c(simpleTheme(lty=1:8, 
col="black",lwd=2),list(axis.components=list(bottom=list(tck=c(0,1))),layout.heights
 = list(main = 1.2,
   sub  = 0,
   axis.top = 0.2,
   top.padding  = 0.1,
   bottom.padding = 0)) ),
    auto.key = list(x = 0.2, y = 0.9,
    cex = 0.75, points = FALSE, lines = TRUE)) 
j=1
print(xy, pos = c(0.0, 0.5, 0.33, 1.0), more = TRUE)
j=j+1
print(xy, pos = c(0.33, 0.5, 0.66, 1.0), more = TRUE)
j=j+1
print(xy, pos = c(0.66, 0.5, 0.99, 1.0), more = TRUE)
j=j+1
print(xy, pos = c(0.0, 0.0, 0.33, 0.5), more = TRUE)
j=j+1
print(xy, pos = c(0.33, 0.0, 0.66, 0.5), more = TRUE)
j=j+1
print(xy, pos = c(0.66, 0.0, 0.99, 0.5), more = FALSE)

Many thanks,
Lisa




- Original Message -
From: Lisa Daniel 
To: "r-help@r-project.org" 
Cc: 
Sent: Thursday, February 14, 2013 12:14 PM
Subject: Alternate tick labels in xyplot

Dear Rhelp,

I would like to get alternate tick labels for the xyplot:
library(lattice)
library(grid)

xy <-xyplot(decrease ~ treatment, OrchardSprays,
    main= "Some plot",
    groups = rowpos, type = "a",
        page = function(n){
 grid.text(LETTERS[j],
 y = 0.95,
 x = 0.15,
 default.units = "npc",
 just = c("left"),
 gp = gpar(fontsize = 12,fontface="bold") )
   },
    par.settings = c(simpleTheme(lty=1:8, 
col="black",lwd=2),list(layout.heights = list(main = 1.2,
   sub  = 0,
   axis.top = 0.2,
   top.padding  = 0.1,
   bottom.padding = 0)) ),
    auto.key = list(x = 0.2, y = 0.9,
    cex = 0.75, points = FALSE, lines = TRUE)) 
j=1
print(xy, pos = c(0.0, 0.5, 0.33, 1.0), more = TRUE)
j=j+1
print(xy, pos = c(0.33, 0.5, 0.66, 1.0), more = TRUE)
j=j+1
print(xy, pos = c(0.66, 0.5, 0.99, 1.0), more = TRUE)
j=j+1
print(xy, pos = c(0.0, 0.0, 0.33, 0.5), more = TRUE)
j=j+1
print(xy, pos = c(0.33, 0.0, 0.66, 0.5), more = TRUE)
j=j+1
print(xy, pos = c(0.66, 0.0, 0.99, 0.5), more = FALSE)


similar to the x-axis in the code below, but somehow it is not working when I 
pasted 'list(axis.components=...) in the above code:
xyplot(rnorm(12) ~ 1:12 , type="l",
scales=list(x=list(at=seq(2,12,2),labels=c(1, ' ', 3 , ' ' , 5 , ' ' ))),
par.settings=list(axis.components=list(bottom=list(tck=c(0,1) 

scales=list(x=list(at=seq(1,8,1),labels=c('A', ' ', 'C', ' ' ,'E' , ' ','G',' 
'))),

If possible, I would like a heading for each rows (justified to center) above 
the individual heading.

Please help.
Many thanks,
Lisa.


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Alternate tick labels in xyplot

2013-02-14 Thread Lisa Daniel


Dear David and Duncan,

Thank you for the responses.

David:

I was able to fix it with grid.text().

Duncan:
I would certainly look into ?scale.components in latticeExtra package 
(xscale.components.default)

The code for the figure is below.
library(lattice)
library(grid)

xy <-xyplot(decrease ~ treatment, OrchardSprays,
    main= "Some plot",
    groups = rowpos, type = "a",
    scales=list(x=list(at=seq(1,8,1),labels=c('A','','C','','E','','G',''))),
        page = function(n){
 grid.text(LETTERS[j],
 y = 0.95,
 x = 0.15,
 default.units = "npc",
 just = c("left"),
 gp = gpar(fontsize = 12,fontface="bold") )
   },
    par.settings = c(simpleTheme(lty=1:8, 
col="black",lwd=2),list(axis.components=list(bottom=list(tck=c(0,1))),layout.heights
 = list(main = 1.2,
   sub  = 0,
   axis.top = 0.2,
   top.padding  = 0.1,
   bottom.padding = 0,
            axis.bottom=0.8)) ),
    auto.key = list(x = 0.2, y = 0.9,
    cex = 0.75, points = FALSE, lines = TRUE)) 
j=1
print(xy, pos = c(0.0, 0.50, 0.33, 0.95), more = TRUE)
j=j+1
print(xy, pos = c(0.33, 0.50, 0.66, 0.95), more = TRUE)
j=j+1
print(xy, pos = c(0.66, 0.50, 0.99, 0.95), more = TRUE)
j=j+1
print(xy, pos = c(0.0, 0.0, 0.33, 0.45), more = TRUE)
j=j+1
print(xy, pos = c(0.33, 0.0, 0.66, 0.45), more = TRUE)
j=j+1
print(xy, pos = c(0.66, 0.0, 0.99, 0.45), more = FALSE)
grid.text("Upper row", x=0.5, y=0.97, gp=gpar(fontsize=12, col="black"))
grid.text("Lower row", x=0.5, y=0.47, gp=gpar(fontsize=12, col="black"))



Thanks,
Lisa


- Original Message -
From: David Winsemius 
To: Lisa Daniel 
Cc: "r-help@r-project.org" 
Sent: Thursday, February 14, 2013 4:31 PM
Subject: Re: [R] Alternate tick labels in xyplot


On Feb 14, 2013, at 10:52 AM, Lisa Daniel wrote:

> Dear Rhelp,
> I was able to solve the tick labels part.  If somebody can help me in 
> creating title for each row of figures above the individual headings, it will 
> be great.

I think you need to be looking at grid.text() in package grid.

> library(grid)
> library(lattice)
> xy <-xyplot(decrease ~ treatment, OrchardSprays,
>     main= "Some plot",
>         groups = rowpos, type = "a",
>     scales=list(x=list(at=seq(1,8,1),labels=c('A','','C','','E','','G',''))),
>                 page     = function(n){
>                          grid.text(LETTERS[j],
>                          y = 0.95,
>                          x = 0.15,
>                          default.units = "npc",
>                          just = c("left"),
>                          gp = gpar(fontsize = 12,fontface="bold") )
>                        },
>     par.settings = c(simpleTheme(lty=1:8, 
>col="black",lwd=2),list(axis.components=list(bottom=list(tck=c(0,1))),layout.heights
> = list(main = 1.2,
>                        sub  = 0,
>                        axis.top = 0.2,
>                        top.padding  = 0.1,
>                        bottom.padding = 0)) ),
>         auto.key = list(x = 0.2, y = 0.9,
>         cex = 0.75, points = FALSE, lines = TRUE)) 
> j=1
> print(xy, pos = c(0.0, 0.5, 0.33, 1.0), more = TRUE)
> j=j+1
> print(xy, pos = c(0.33, 0.5, 0.66, 1.0), more = TRUE)
> j=j+1
> print(xy, pos = c(0.66, 0.5, 0.99, 1.0), more = TRUE)
> j=j+1
> print(xy, pos = c(0.0, 0.0, 0.33, 0.5), more = TRUE)
> j=j+1
> print(xy, pos = c(0.33, 0.0, 0.66, 0.5), more = TRUE)
> j=j+1
> print(xy, pos = c(0.66, 0.0, 0.99, 0.5), more = FALSE)
> 
> Many thanks,
> Lisa
> 
> 
> 
> 
> - Original Message -
> From: Lisa Daniel 
> To: "r-help@r-project.org" 
> Cc: 
> Sent: Thursday, February 14, 2013 12:14 PM
> Subject: Alternate tick labels in xyplot
> 
> Dear Rhelp,
> 
> I would like to get alternate tick labels for the xyplot:
> library(lattice)
> library(grid)
> 
> xy <-xyplot(decrease ~ treatment, OrchardSprays,
>     main= "Some plot",
>         groups = rowpos, type = "a",
>                 page     = function(n){
>                          grid.text(LETTERS[j],
>                          y = 0.95,
>                          x = 0.15,
>                          default.units = "npc",
>                          just = c("left"),
>                          gp = gpar(fontsize =

[R] xyplot and barplot in the same page

2013-02-27 Thread Lisa Daniel
Dear Rhelp,

I am trying to get multiple xyplots and barplots in the same page.  I couldn't 
get it work.
Example code:
library(lattice)
library(grid)
xy <-xyplot(decrease ~ treatment, OrchardSprays,
    main= "Some plot",
    groups = rowpos, type = "a",
    scales=list(x=list(at=seq(1,8,1),labels=c('A','','C','','E','','G',''))),
        page = function(n){
 grid.text(LETTERS[j],
 y = 0.95,
 x = 0.15,
 default.units = "npc",
 just = c("left"),
 gp = gpar(fontsize = 12,fontface="bold") )
   },
    par.settings = c(simpleTheme(lty=1:8, 
col="black",lwd=2),list(axis.components=list(bottom=list(tck=c(0,1))),layout.heights
 = list(main = 1.2,
   sub  = 0,
   axis.top = 0.2,
   top.padding  = 0.1,
   bottom.padding = 0,
            axis.bottom=0.8)) ),
    auto.key = list(x = 0.2, y = 0.9,
    cex = 0.75, points = FALSE, lines = TRUE)) 
j=1
print(xy, pos = c(0.0, 0.50, 0.33, 0.95), more = TRUE)
j=j+1
print(xy, pos = c(0.33, 0.50, 0.66, 0.95), more = TRUE)
j=j+1
print(xy, pos = c(0.66, 0.50, 0.99, 0.95), more = TRUE)
j=j+1
print(xy, pos = c(0.0, 0.0, 0.33, 0.45), more = TRUE)
j=j+1
print(xy, pos = c(0.33, 0.0, 0.66, 0.45), more = TRUE)
j=j+1
counts <- table(mtcars$gear)
barplot(counts, main="Car Distribution",  #this part is not correct
   xlab="Number of Gears") 

Thanks in advance,

Lisa


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] X11 font -adobe-helvetica size 15 could not be loaded

2013-04-04 Thread Lisa Daniel
HI All,

I got this Error message, when I tried to plot
 X11 font -adobe-helvetica-%s-%s-*-*-%d-*-*-*-*-*-*-*, face 5 at size 15 could 
not be loaded


sessionInfo()
R version 3.0.0 (2013-04-03)
Platform: x86_64-unknown-linux-gnu (64-bit)

locale:
 [1] LC_CTYPE=en_CA.UTF-8   LC_NUMERIC=C  
 [3] LC_TIME=en_CA.UTF-8    LC_COLLATE=en_CA.UTF-8    
 [5] LC_MONETARY=en_CA.UTF-8    LC_MESSAGES=en_CA.UTF-8   
 [7] LC_PAPER=C LC_NAME=C 
 [9] LC_ADDRESS=C   LC_TELEPHONE=C    
[11] LC_MEASUREMENT=en_CA.UTF-8 LC_IDENTIFICATION=C   

attached base packages:
[1] stats graphics  grDevices utils datasets  methods   base 

other attached packages:
[1] stringr_0.6.2  reshape2_1.2.2

loaded via a namespace (and not attached):
[1] plyr_1.8    tools_3.0.0


I looked online for a solution.and found this 
(https://stat.ethz.ch/pipermail/r-help/2002-June/022116.html).  But, 

/etc/X11 $ ls
app-defaults rgb.txt  xkb   Xresources  Xsession.options
default-display-manager  X    Xreset    Xsession    XvMCConfig
fonts    xinit    Xreset.d  Xsession.d  Xwrapper.config

doesn't have XF86Config

 capabilities("X11")
 X11 
TRUE 
names(X11Fonts())
[1] "serif"    "sans" "mono" "Times"    "Helvetica"   
[6] "CyrTimes" "CyrHelvetica" "Arial"    "Mincho" 


Then, I installed xfonts-100dpi, xfonts-75dpi (Ubuntu-based).
xset -q #output


Font Path:
  /usr/share/fonts/X11/misc,/usr/share/fonts/X11/Type1,built-ins
Regards,
Lisa.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.