[R] plot auto key and text into panels using lattice

2015-07-21 Thread Duncan Mackay
 from there. Its amazing what you find out.

Duncan

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





-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Luigi
Marongiu
Sent: Tuesday, 21 July 2015 08:39
To: r-help
Subject: [R] plot auto key and text into panels using lattice

Dear all,
I am writing some text into several panels which I can do with this
script (in capital the variables):
xyplot(Y ~ X | Z,
   data = DATAFRAME,
   groups = Z,
   ylab= Y,
   xlab=X,
   main=TITLE,
   scales = list(
   x = list(draw = FALSE),
   y = list(draw = FALSE),
   relation=same,
   alternating=TRUE),
   as.table = TRUE,
   layout = LAYOUT,
   par.settings = list(
   strip.background=list(col=white),
   axis.text = list(cex = 0.6),
   par.xlab.text = list(cex = 0.75),
   par.ylab.text = list(cex = 0.75),
   par.main.text = list(cex = 0.8),
   superpose.symbol = list(pch = ., cex = 1)
   ),
   strip= FALSE,
   type = l,
   col = 3,
   panel = function(x, y,...) {
   panel.xyplot(x,y,...)
   panel.text(MIN.X+(0.1*MAX.X),
  MAX.Y-(0.1*MAX.Y),
  labels=LABELS[panel.number()],
  cex=0.3
  )
   }
)

A similar plot also add the autokey because it takes in account two
different Y values, but the plot is not drawn rather the function is
implemented but the plot remains empty:
xyplot(Y1+Y2 ~ X | Z,
   data = DATAFRAME,
   ylab= Y,
   xlab=X,
   main=TITLE,
   scales = list(
   x = list(draw = FALSE),
   y = list(draw = FALSE),
   relation=same,
   alternating=TRUE),
   as.table = TRUE,
   layout = LAYOUT,
   auto.key= list(space = centre),
   par.settings = list(
   strip.background=list(col=white),
   axis.text = list(cex = 0.6),
   par.xlab.text = list(cex = 0.75),
   par.ylab.text = list(cex = 0.75),
   par.main.text = list(cex = 0.8),
   superpose.symbol = list(pch = ., cex = 1)
   ),
   strip= FALSE,
   type = l,
   col =  c(4,2),
   key = list(
   space=top, columns=2,
   text=list(TEXT_FOR_AUTOKEY, col=black),
   lines=list(col=c(4,2)),
   panel = panel.superpose
),
   panel = function(x, y,...)
   {
   panel.xyplot(x,y,...)
   panel.text(MIN.X+(0.1*MAX.X),
  MAX.Y-(0.1*MAX.Y),
  labels=LAB[panel.number()],
  cex=0.3,
  panel = panel.superpose
  )

   }
)


I am not attaching actual data because I believe the problem is in the
actual call, maybe I am using twice panel.superimpose, although
several combination I made (for instance moving the key argument into
the panel function) did not solve the problem.
Could you tell me where I am getting it wrong?
Thank you.
best regards
Luigi

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] plot auto key and text into panels using lattice

2015-07-20 Thread Luigi Marongiu
Dear all,
I am writing some text into several panels which I can do with this
script (in capital the variables):
xyplot(Y ~ X | Z,
   data = DATAFRAME,
   groups = Z,
   ylab= Y,
   xlab=X,
   main=TITLE,
   scales = list(
   x = list(draw = FALSE),
   y = list(draw = FALSE),
   relation=same,
   alternating=TRUE),
   as.table = TRUE,
   layout = LAYOUT,
   par.settings = list(
   strip.background=list(col=white),
   axis.text = list(cex = 0.6),
   par.xlab.text = list(cex = 0.75),
   par.ylab.text = list(cex = 0.75),
   par.main.text = list(cex = 0.8),
   superpose.symbol = list(pch = ., cex = 1)
   ),
   strip= FALSE,
   type = l,
   col = 3,
   panel = function(x, y,...) {
   panel.xyplot(x,y,...)
   panel.text(MIN.X+(0.1*MAX.X),
  MAX.Y-(0.1*MAX.Y),
  labels=LABELS[panel.number()],
  cex=0.3
  )
   }
)

A similar plot also add the autokey because it takes in account two
different Y values, but the plot is not drawn rather the function is
implemented but the plot remains empty:
xyplot(Y1+Y2 ~ X | Z,
   data = DATAFRAME,
   ylab= Y,
   xlab=X,
   main=TITLE,
   scales = list(
   x = list(draw = FALSE),
   y = list(draw = FALSE),
   relation=same,
   alternating=TRUE),
   as.table = TRUE,
   layout = LAYOUT,
   auto.key= list(space = centre),
   par.settings = list(
   strip.background=list(col=white),
   axis.text = list(cex = 0.6),
   par.xlab.text = list(cex = 0.75),
   par.ylab.text = list(cex = 0.75),
   par.main.text = list(cex = 0.8),
   superpose.symbol = list(pch = ., cex = 1)
   ),
   strip= FALSE,
   type = l,
   col =  c(4,2),
   key = list(
   space=top, columns=2,
   text=list(TEXT_FOR_AUTOKEY, col=black),
   lines=list(col=c(4,2)),
   panel = panel.superpose
),
   panel = function(x, y,...)
   {
   panel.xyplot(x,y,...)
   panel.text(MIN.X+(0.1*MAX.X),
  MAX.Y-(0.1*MAX.Y),
  labels=LAB[panel.number()],
  cex=0.3,
  panel = panel.superpose
  )

   }
)


I am not attaching actual data because I believe the problem is in the
actual call, maybe I am using twice panel.superimpose, although
several combination I made (for instance moving the key argument into
the panel function) did not solve the problem.
Could you tell me where I am getting it wrong?
Thank you.
best regards
Luigi

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.