Skip to content

high density plots using lattice dotplot()

1 message · Duncan Mackay

#
Hi Luigi

Try

set.seed(1)

PLATE <-
data.frame(Delta.Rn = rnorm(500),
           Cycle = rnorm(500),
           Delta2 = rnorm(500)+1,
           Well  = rep(1:50, each = 10))
head(PLATE,10)

xyplot(Delta.Rn+Delta2 ~ Cycle | Well,
         data = subset(PLATE, Well %in% 1:49),
         allow.multiple = TRUE,
         ylab="Fluorescence (Delta Rn)",
         xlab="Cycles",
         main="TITLE",
         scales = list(
           x = list(draw = FALSE),
           y = list(draw = FALSE),
           relation="same",
           alternating=TRUE),
         as.table = TRUE,
         layout = c(10,5),
         par.settings = list(
           strip.background=list(col="white"),
           # layout.heights = list(strip = 0.8),
           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 = 2,
                                   col = c(2,4) )
         ),
         strip    = FALSE,
         type = "p",
         key = list(text = list(label = c("Delta.Rn","Delta2")),
                    points = list(cex = 0.6, pch = 16, col = c(2,4)),
                    cex = 0.6,
                    x = 0.9,
                    y = 0.1),
         panel = panel.superpose,
         panel.groups = function(x,y,...){

                   panel.xyplot(x,y,... )

                   # text argument can be a vector of values not
                   # necessarily the group name
                   pnl = panel.number()  # needed as group.number if added is now either 1 or 2
                  
                   grid.text(c(LETTERS,letters)[pnl],
                             y = 0.93, x = 0.5,
                             default.units = "npc",
                             just = c("left", "bottom"),
                             gp = gpar(fontsize = 7) )

         }
  )

Remember to delete the group argument (I forgot to at first as the groups are now Delta.Rn Delta2)
You may have 1+ empty panels so put the legend there where ever it is just amend the x and y or fine tune them
you can have the pch = "." and increase cex but  it will become as square with large cex
Duncan


-----Original Message-----
From: Luigi Marongiu [mailto:marongiu.luigi at gmail.com] 
Sent: Thursday, 23 April 2015 10:05
To: Duncan Mackay
Subject: Re: [R] high density plots using lattice dotplot()

Dear Duncan,
sorry to come back so soon, but i wanted to ask you whether it would
be  possible to plot two sets of lines within each box, let's say a
main value A and a secondary value B. In normal plots I could use a
plot() followed by points(); what would be the strategy here?
Thank you again,
best regards,
Luigi
On Wed, Apr 22, 2015 at 6:46 AM, Duncan Mackay <dulcalma at bigpond.com> wrote: