Re: [R] lattice plot formatting: pch, abbreviation and labels

2014-04-29 Thread Duncan Mackay
Hi Luigi

Only minor changes needed.

When you go back to a normal xyplot the rules of ratio variables apply the 
x-axis default in your case something like pretty(range(x)
So the x-axis limits range from 0-1 
and the panel limits therefore are 0-1 +/- 4%
With strip stripplot being categorical the limits are for values 1 and 2 so the 
top value for 2 is not being shown
(easily seen with str(xyplot object))

You missed out the assigning of groups to the segments.
You could do this by a for loop of 1:2 or by using groups/panel.groups.
I have not got the time to dig out the code to do it at the moment.

xyplot(copy ~ positivity|stimulation, data = my.data,
   group = factor(positivity),
   as.table = TRUE,
   layout = c(8,1),
   xlim  = c(-1,2),
   scales = list(x = list(at = c(0,1), 
 labels = c(N,P),
 rot = 0)),
  jitter.data=TRUE, 
  pch=c(16,1),
  col=black,
  ylab=expression(bold(Copy)),
  xlab=expression(bold(Stimulation)),
  main=Plot,
  par.settings = list(strip.background=list(col=white)),
 par.strip.text=list(font=2),
  key = list(space=top,
 columns=2,
 text=list(c(Positive, Negative), col=black),
 points=list(pch=c(16,1), col=black)),
  panel = function(x, y,...){
pnl = panel.number()
#panel.abline(h = datmeA[datmeA[,2]== 
levels(datmeA[,2])[pnl],ratio], col = c(red,black), lty=3)
#for (j in 1:2){
#  with(subset(datmeA, (positivity == j-1  stimulation == 
levels(datmeA$stimulation)[pnl])),
# panel.abline(h = copy, lwd = 1, col = 
c(red,black)[j], lty = 1) )
   for (j in 1:2){
panel.segments(x0 = (j-1)-0.25, y0 =  datmeA[datmeA[,2]== 
levels(datmeA[,2])[pnl],copy], # amend to copy
 x1 = (j-1)+0.25,  y1 = datmeA[datmeA[,2]== 
levels(datmeA[,2])[pnl],copy],
 lwd = 2, col = c(magenta,grey)[j])
}

   panel.stripplot(x,y, ...)
}
  )
If you wanted full N P then

   scales = list(x = list(at = c(0,1),
 alternating = F,
 labels = c(Negative,Positive),
 rot = 90)),  # rot = 0 if labels as before

Duncan

-Original Message-
From: Luigi Marongiu [mailto:marongiu.lu...@gmail.com] 
Sent: Tuesday, 29 April 2014 04:34
To: Duncan Mackay
Subject: Re: [R] lattice plot formatting: pch, abbreviation and labels

Dear Duncan,
sorry to pester you again with this, but probably the solution is
getting closer. following one of your previous tips i could write the
xyplot synthax as you suggested:

library(lattice)
my.data-structure(list(
   column_1 = 1:120,
   column_2 = structure(c(
 1,2,3,4,5,6,7,8,
 1,2,3,4,5,6,7,8,
 1,2,3,4,5,6,7,8,
 1,2,3,4,5,6,7,8,
 1,2,3,4,5,6,7,8,
 1,2,3,4,5,6,7,8,
 1,2,3,4,5,6,7,8,
 1,2,3,4,5,6,7,8,
 1,2,3,4,5,6,7,8,
 1,2,3,4,5,6,7,8,
 1,2,3,4,5,6,7,8,
 1,2,3,4,5,6,7,8,
 1,2,3,4,5,6,7,8,
 1,2,3,4,5,6,7,8,
 1,2,3,4,5,6,7,8), .Label = c(Unst., ESAT6, CFP10, Rv3615c,
Rv2654, Rv3879, Rv3873, PHA), class = factor),
 column_3 = structure(c(
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,
1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,
0,0,0,0,0,0,0,0)),
 column_4 = c(
 
192.0519108,183.6403531,53.46798757,83.60638077,69.60749873,159.4706861,256.8765622,499.2899303,
 
2170.799076,1411.349719,2759.472348,2098.973397,2164.739515,1288.676574,1611.486543,6205.229575,
 
870.7424981,465.9967135,191.8962375,864.0937485,2962.693675,1289.259137,2418.651212,7345.712517,
 0,168.1198893,674.4342961,101.1575401,47.81596237,0,0,1420.793922,
 
142.6871331,5.466468742,291.9564635,80.73914133,73.02239621,64.47806871,144.3543635,3167.959757,
 
3164.748333,1092.634557,28733.20269,1207.87783,729.6090973,151.8706088,241.2466141,9600.963594,
 
1411.718287,12569.96285,1143.254476,6317.378481,16542.27718,79.68025792,1958.495138,7224.503437,
 
208.4382941,69.48609769,656.691151,0.499017582,7114.910926,187.6296174,41.73980805,8930.784541,
 
4.276752185,0.432300363,60.89228665,1.103924786,0.490686366,1.812993239,7.264531581,1518.610307,
 
2172.051528,595.8513744,17141.84336,589.6565971,1340.287628,117.350942,593.7034054,24043.61463,
 
0,81.83292179,1539.864321,36.41722958,8.385131047,161.7647376,65.21615696,7265.573875,
 
97.84753179,154.051827,0.613835842,10.06138851,45.04879285,176.8284258,18795.75462,30676.769,
 
5780.34957,944.2200834,2398.235596,1083.393165,2541.714557,1251.670895,1547.178549,1792.679176,
 
3067.988416,8117.210173,23676.02226,8251.937547,17360.80494,18563.61561,16941.865,31453.96708

Re: [R] lattice plot formatting: pch, abbreviation and labels

2014-04-29 Thread Duncan Mackay
Hi Luigi

Only minor changes needed.

When you go back to a normal xyplot the rules of ratio variables apply the 
x-axis default in your case something like pretty(range(x)
So the x-axis limits range from 0-1 
and the panel limits therefore are 0-1 +/- 4%
With strip stripplot being categorical the limits are for values 1 and 2 so the 
top value for 2 is not being shown
(easily seen with str(xyplot object))

You missed out the assigning of groups to the segments.
You could do this by a for loop of 1:2 or by using groups/panel.groups.
I have not got the time to dig out the code to do it at the moment.

xyplot(copy ~ positivity|stimulation, data = my.data,
   group = factor(positivity),
   as.table = TRUE,
   layout = c(8,1),
   xlim  = c(-1,2),
   scales = list(x = list(at = c(0,1), 
 labels = c(N,P),
 rot = 0)),
  jitter.data=TRUE, 
  pch=c(16,1),
  col=black,
  ylab=expression(bold(Copy)),
  xlab=expression(bold(Stimulation)),
  main=Plot,
  par.settings = list(strip.background=list(col=white)),
 par.strip.text=list(font=2),
  key = list(space=top,
 columns=2,
 text=list(c(Positive, Negative), col=black),
 points=list(pch=c(16,1), col=black)),
  panel = function(x, y,...){
pnl = panel.number()
#panel.abline(h = datmeA[datmeA[,2]== 
levels(datmeA[,2])[pnl],ratio], col = c(red,black), lty=3)
#for (j in 1:2){
#  with(subset(datmeA, (positivity == j-1  stimulation == 
levels(datmeA$stimulation)[pnl])),
# panel.abline(h = copy, lwd = 1, col = 
c(red,black)[j], lty = 1) )
   for (j in 1:2){
panel.segments(x0 = (j-1)-0.25, y0 =  datmeA[datmeA[,2]== 
levels(datmeA[,2])[pnl],copy], # amend to copy
 x1 = (j-1)+0.25,  y1 = datmeA[datmeA[,2]== 
levels(datmeA[,2])[pnl],copy],
 lwd = 2, col = c(magenta,grey)[j])
}

   panel.stripplot(x,y, ...)
}
  )
If you wanted full N P then

   scales = list(x = list(at = c(0,1),
 alternating = F,
 labels = c(Negative,Positive),
 rot = 90)),  # rot = 0 if labels as before

Duncan

-Original Message-
From: Luigi Marongiu [mailto:marongiu.lu...@gmail.com] 
Sent: Tuesday, 29 April 2014 04:34
To: Duncan Mackay
Subject: Re: [R] lattice plot formatting: pch, abbreviation and labels

Dear Duncan,
sorry to pester you again with this, but probably the solution is
getting closer. following one of your previous tips i could write the
xyplot synthax as you suggested:

library(lattice)
my.data-structure(list(
   column_1 = 1:120,
   column_2 = structure(c(
 1,2,3,4,5,6,7,8,
 1,2,3,4,5,6,7,8,
 1,2,3,4,5,6,7,8,
 1,2,3,4,5,6,7,8,
 1,2,3,4,5,6,7,8,
 1,2,3,4,5,6,7,8,
 1,2,3,4,5,6,7,8,
 1,2,3,4,5,6,7,8,
 1,2,3,4,5,6,7,8,
 1,2,3,4,5,6,7,8,
 1,2,3,4,5,6,7,8,
 1,2,3,4,5,6,7,8,
 1,2,3,4,5,6,7,8,
 1,2,3,4,5,6,7,8,
 1,2,3,4,5,6,7,8), .Label = c(Unst., ESAT6, CFP10, Rv3615c,
Rv2654, Rv3879, Rv3873, PHA), class = factor),
 column_3 = structure(c(
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,
1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,
0,0,0,0,0,0,0,0)),
 column_4 = c(
 
192.0519108,183.6403531,53.46798757,83.60638077,69.60749873,159.4706861,256.8765622,499.2899303,
 
2170.799076,1411.349719,2759.472348,2098.973397,2164.739515,1288.676574,1611.486543,6205.229575,
 
870.7424981,465.9967135,191.8962375,864.0937485,2962.693675,1289.259137,2418.651212,7345.712517,
 0,168.1198893,674.4342961,101.1575401,47.81596237,0,0,1420.793922,
 
142.6871331,5.466468742,291.9564635,80.73914133,73.02239621,64.47806871,144.3543635,3167.959757,
 
3164.748333,1092.634557,28733.20269,1207.87783,729.6090973,151.8706088,241.2466141,9600.963594,
 
1411.718287,12569.96285,1143.254476,6317.378481,16542.27718,79.68025792,1958.495138,7224.503437,
 
208.4382941,69.48609769,656.691151,0.499017582,7114.910926,187.6296174,41.73980805,8930.784541,
 
4.276752185,0.432300363,60.89228665,1.103924786,0.490686366,1.812993239,7.264531581,1518.610307,
 
2172.051528,595.8513744,17141.84336,589.6565971,1340.287628,117.350942,593.7034054,24043.61463,
 
0,81.83292179,1539.864321,36.41722958,8.385131047,161.7647376,65.21615696,7265.573875,
 
97.84753179,154.051827,0.613835842,10.06138851,45.04879285,176.8284258,18795.75462,30676.769,
 
5780.34957,944.2200834,2398.235596,1083.393165,2541.714557,1251.670895,1547.178549,1792.679176,
 
3067.988416,8117.210173,23676.02226,8251.937547,17360.80494,18563.61561,16941.865,31453.96708

Re: [R] lattice plot formatting: pch, abbreviation and labels

2014-04-29 Thread Duncan Mackay
Forgot to cc to list
Hi Luigi

Our emails are apparently crossing

What you are doing is referencing down ONLY to the stimulation level and not
 the stimulation level + productivity level required  for each of the N and P 
groups

notch-0.3
stripplot(
  copy ~ factor(positivity)|factor(stimulation, levels = c(Unst.,
ESAT6,CFP10,Rv3615c, Rv2654,Rv3879, Rv3873,PHA)),
   my.data,
   group = positivity,
   hor=F,
   layout = c(8,1),
   scales = list(x = list(at = c(1,2), labels = c(N,P))),
   jitter.data=TRUE, pch=c(16,1), col=black,
   ylab=expression(bold(Copy)),
   xlab=expression(bold(Stimulation)),
   main=Plot,
   par.settings = list(strip.background=list(col=white)),
   par.strip.text=list(font=2),
   key = key.plot,
   panel = function(x, y, ...)
  {
pnl = panel.number()
   for (i in 1:2){
  datme-subset(datmeA, positivity==i-1)
 w-i+k
 panel.segments(x0 = X[w], y0 =  datme[datme[,2]== 
levels(datme[,2])[pnl],copy],
x1 = X[w+1],  y1 = datme[datme[,2]== 
levels(datme[,2])[pnl],copy],lwd = 2, col = black)
  k=k+1

  panel.stripplot(x,y, ...)

  panel.stripplot(x,y, ...)
   }
 }
   )
   
   for (i in 1:2){
  datme-subset(datmeA, positivity==i-1)
 w-i+k
 panel.segments(x0 = X[w], y0 =  datme[datme[,2]== 
levels(datme[,2])[pnl],copy],
x1 = X[w+1],  y1 = datme[datme[,2]== 
levels(datme[,2])[pnl],copy],lwd = 2, col = black)
  k=k+1

  panel.stripplot(x,y, ...)

the more lattice way is

notch-0.3
stripplot(
  copy ~ factor(positivity)|factor(stimulation, levels = c(Unst.,
ESAT6,CFP10,Rv3615c, Rv2654,Rv3879, Rv3873,PHA)),
   my.data,
   group = positivity,
   hor=F,
   layout = c(8,1),
   scales = list(x = list(at = c(1,2), labels = c(N,P))),
   jitter.data=TRUE, pch=c(16,1), col=black,
   ylab=expression(bold(Copy)),
   xlab=expression(bold(Stimulation)),
   main=Plot,
   par.settings = list(strip.background=list(col=white)),
   par.strip.text=list(font=2),
   key = key.plot,
   panel = panel.superpose,
   panel.groups = function(x, y, group.number, ...) {

panel.segments(x0= x-notch, x1=x+notch, y0=mean(y), 
y1=mean(y), lty = c(1:2)[group.number],
lwd=c(2:1)[group.number], col = c(1:2)[group.number])

panel.stripplot(x,y, ...)
 }
  )

Duncan

-Original Message-
From: Luigi Marongiu [mailto:marongiu.lu...@gmail.com] 
Sent: Wednesday, 30 April 2014 02:44
To: Duncan Mackay
Subject: Re: [R] lattice plot formatting: pch, abbreviation and labels

Dear Duncan,
I think the solution is close by. I can now plot the segments directly
with stripplot using a vector containing the required positions; the
only problem is to generate 4 consecutive indeces using two nested
loops -- using the subtraction of the index and a number I obtained
the duplication of the values, as you can see in the second example.
Many thanks,
Luigi

X-c(0.7, 1.3, 1.7, 2.3)
stripplot(
  copy ~ factor(positivity)|factor(stimulation, levels = c(Unst.,
ESAT6,CFP10,Rv3615c, Rv2654,Rv3879, Rv3873,PHA)),
   my.data,
   group = positivity,
   hor=F,
   layout = c(8,1),
   scales = list(x = list(at = c(1,2), labels = c(N,P))),
   jitter.data=TRUE, pch=c(16,1), col=black,
   ylab=expression(bold(Copy)),
   xlab=expression(bold(Stimulation)),
   main=Plot,
   par.settings = list(strip.background=list(col=white)),
   par.strip.text=list(font=2),
   key = key.plot,
   panel = function(x, y, ...)
  {
pnl = panel.number()
  for (i in 1:2){
   datme-subset(datmeA, positivity==i-1)
   k-i-1
 for (j in 1:2)
{
   panel.segments(x0 = X[k+j], y0 =  datme[datme[,2]==
levels(datme[,2])[pnl],copy],
  x1 = X[k+j+1],  y1 =
datme[datme[,2]== levels(datme[,2])[pnl],copy],lwd = 2, col =
c(magenta,grey))
   }

  panel.stripplot(x,y, ...)
   }
 }
   )



 this approach gives duplications:
notch-0.3
stripplot(
  copy ~ factor(positivity)|factor(stimulation, levels = c(Unst.,
ESAT6,CFP10,Rv3615c, Rv2654,Rv3879, Rv3873,PHA)),
   my.data,
   group = positivity,
   hor=F,
   layout = c(8,1),
   scales = list(x = list(at = c(1,2), labels = c(N,P))),
   jitter.data=TRUE, pch=c(16,1), col=black,
   ylab=expression(bold(Copy)),
   xlab=expression(bold(Stimulation)),
   main=Plot,
   par.settings = list(strip.background=list(col=white)),
   par.strip.text=list(font=2),
   key = key.plot,
   panel = function(x, y, ...)
  {
pnl = panel.number()
  for (i in 1:2){
   datme-subset(datmeA, positivity==i-1)
   k-i-1
 for (j in 1:2

Re: [R] lattice plot formatting: pch, abbreviation and labels

2014-04-27 Thread Duncan Mackay
Hi Luigi

Here are 2 ways of doing it.

The first is a cheats way ie easy.

The second is a substitute for the proper way who's code eludes me at the 
moment. I changed the lty on the ablines  as it appears confusing and as you 
are bolding it seems more appropriate. A better way may be to change 1 line 
type.

stripplot(copy ~ factor(positivity)|factor(stimulation, levels = c(Unst., 
ESAT6,CFP10,Rv3615c, Rv2654,Rv3879, Rv3873,PHA)),
  my.data,
  group = positivity,
  hor=F,
  layout = c(8,1),
  scales = list(x = list(at = c(1,2), labels = c(N,P))),
  jitter.data=TRUE, pch=c(16,1), col=black,
  ylab=expression(bold(Copy)),
  xlab=expression(bold(Stimulation)),
  main=Plot,
  par.settings = list(strip.background=list(col=white)),
par.strip.text=list(font=2),
  key = list(space=top,
 columns=2,
 text=list(c(Positive, Negative), col=black),
 points=list(pch=c(16,1), col=black)),
  panel = function(x, y,...){
  pnl = panel.number()
  #panel.abline(h = datmeA[datmeA[,2]== 
levels(datmeA[,2])[pnl],ratio], col = c(red,black), lty=3)

  panel.average(x, y, fun = mean, horizontal = F, lty = 3, col.line 
= c(red,black), type = l)

  panel.stripplot(x,y, ...)
}
  )

stripplot(copy ~ factor(positivity)|factor(stimulation, levels = c(Unst., 
ESAT6,CFP10,Rv3615c, Rv2654,Rv3879, Rv3873,PHA)),
  my.data,
  group = positivity,
  hor=F,
  layout = c(8,1),
  scales = list(x = list(at = c(1,2), labels = c(N,P))),
  jitter.data=TRUE, pch=c(16,1), col=black,
  ylab=expression(bold(Copy)),
  xlab=expression(bold(Stimulation)),
  main=Plot,
  par.settings = list(strip.background=list(col=white)),
par.strip.text=list(font=2),
  key = list(space=top,
 columns=2,
 text=list(c(Positive, Negative), col=black),
 points=list(pch=c(16,1), col=black)),
  panel = function(x, y,...){
pnl = panel.number()
#panel.abline(h = datmeA[datmeA[,2]== 
levels(datmeA[,2])[pnl],ratio], col = c(red,black), lty=3)
for (j in 1:2){
  with(subset(datmeA, (positivity == j-1  stimulation == 
levels(datmeA$stimulation)[pnl])),
 panel.abline(h = copy, lwd = 1, col = c(red,black)[j], 
lty = 1) )

  }

   panel.stripplot(x,y, ...)
}
  )

Remember abline and panel.abline etc only take 1 line at a time so if you have 
more than 1 group you have 2 call it more than once 

Regards 
Duncan

-Original Message-
From: Luigi Marongiu [mailto:marongiu.lu...@gmail.com] 
Sent: Monday, 28 April 2014 04:03
To: Duncan Mackay
Subject: Re: [R] lattice plot formatting: pch, abbreviation and labels

Dear Duncan,
may I bother you a bit more with the same data set? I would like now
to add a segment corresponding to the median values, as we discussed
antecedently.
I have tried to use the code you wrote in the previous mails, but it
hasn't worked. First I have found the aggregate medians values and
assigned to datmeA, then pasted the code you wrote, but without
success. Would be possible to substitute the panel.abline with
panel.segments? but in this case how to tell lattice what are the
values for N or P?
Best wishes,
Luigi

CODE
library(lattice)

my.data-structure(list(
   column_1 = 1:120,
   column_2 = structure(c(
 1,2,3,4,5,6,7,8,
 1,2,3,4,5,6,7,8,
 1,2,3,4,5,6,7,8,
 1,2,3,4,5,6,7,8,
 1,2,3,4,5,6,7,8,
 1,2,3,4,5,6,7,8,
 1,2,3,4,5,6,7,8,
 1,2,3,4,5,6,7,8,
 1,2,3,4,5,6,7,8,
 1,2,3,4,5,6,7,8,
 1,2,3,4,5,6,7,8,
 1,2,3,4,5,6,7,8,
 1,2,3,4,5,6,7,8,
 1,2,3,4,5,6,7,8,
 1,2,3,4,5,6,7,8), .Label = c(Unst., ESAT6, CFP10, Rv3615c,
Rv2654, Rv3879, Rv3873, PHA), class = factor),
column_3 = structure(c(
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,
1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,
0,0,0,0,0,0,0,0)),
 column_4 = c(
 
192.0519108,183.6403531,53.46798757,83.60638077,69.60749873,159.4706861,256.8765622,499.2899303,
 
2170.799076,1411.349719,2759.472348,2098.973397,2164.739515,1288.676574,1611.486543,6205.229575,
 
870.7424981,465.9967135,191.8962375,864.0937485,2962.693675,1289.259137,2418.651212,7345.712517,
 0,168.1198893,674.4342961,101.1575401,47.81596237,0,0,1420.793922,
 
142.6871331,5.466468742,291.9564635,80.73914133,73.02239621,64.47806871,144.3543635,3167.959757,
 
3164.748333,1092.634557,28733.20269,1207.87783,729.6090973,151.8706088,241.2466141,9600.963594,
 
1411.718287,12569.96285,1143.254476,6317.378481,16542.27718,79.68025792,1958.495138,7224.503437,
 
208.4382941,69.48609769,656.691151,0.499017582,7114.910926,187.6296174,41.73980805,8930.784541

Re: [R] lattice plot formatting: pch, abbreviation and labels

2014-04-26 Thread Duncan Mackay
Hi Luigi

You are typing things unnecessarily: do not use the attach command unless
absolutely necessary - it has unfortunate consequences.
It is better to use with or within.
alpha is not available with some devices with bad consequences if used; its
default is 1 anyway.

Once you have stated a data.frame as the data object it is usually not
necessary to use the data.frame$ sign in to signify column names: use the
column names.
data = a data.frame is the equivalent to with

You are reordering the levels of stimulation and changing the name of 1 so I
thought it was easiest to make a column stim and do things there otherwise
it the relevelling could be done in the data argument using the subset
argument. Then the change to Unst could be done by using  strip=
strip.custom(factor.levels = ...),

To change for the -/+ I made a group - the easiest way.
Have a look a changing the negative symbol to 20 or something else as it is
hard to visualise. You may vary things with changing cex (remember to have 2
values 1 for each group).

If you do str(xyplot object) you will get a big print of the object and
within that the x limits are shown as 0, 1 which means that the x values
are 1 and 2
There is a command to get these things but I have forgotten it

my.data$stimulation - factor(levels = c(Unstimulated,
ESAT6,CFP10,Rv3615c,Rv2654, Rv3879, Rv3873,PHA))
my.data$stim - factor(my.data$stimulation, labels = c(Unst.,
ESAT6,CFP10,Rv3615c,Rv2654, Rv3879, Rv3873,PHA))
my.data$pos - ifelse(sign(my.data$copy)  0, 2,1)

  stripplot(copy ~ factor(positivity)|stim,my.data,
groups = pos,
hor = F,
layout = c(8,1),
scales = list(x = list(at = c(1,2),
   labels = c(N,P))),
jitter.x = TRUE,
amount = 2,
pch = c(16,1),
col = black,
ylab = expression(bold(Copy)),
xlab = expression(bold(Stimulation)),
main=Plot,
par.settings = list(strip.background=list(col=white)),
par.strip.text=list(font=2)
)

Regards

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-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Luigi Marongiu
Sent: Sunday, 27 April 2014 02:07
To: r-help@r-project.org
Subject: [R] lattice plot formatting: pch, abbreviation and labels

Dear all,
I am trying to use the lattice plot, but the syntax is quite
difficult. Specifically I have eight variables (1 to 8) each of them
further subdivided in two classes (negative=0 and positive=1). I am
using the stripplot() to represent these values. I would like to
represent the negative and positive values with black and white dots
so I have tried to use the argument pch=c(16, 1) both in the main
stripplot function and embedded in the scale argument. However the
resulting plot shows that some points are drawn with the pch=16 and
other with pch=1 irrespective of their class.
Is there a way to draw the values for the variable positivity = 0 with
pch=16 and those with positivity = 1 with pch=0?

In addition I would like to change the labels under the axis from 0,1
to N,P. However when I placed labels=c(N, P) or labels=list(N,
P) in the main stripplot() I did not obtained any difference and
when placed within the scale argument also the -labels were modified.
Is there a way to change the label 0 with N and the label 1 with P?

final problem: I would like to abbreviate the Unstimulated box label
with Unst.. I have tried the abbreviate=TRUE argument but again the
syntax is too complex for me and it did not work.
Is there a way to abbreviate the variables names?

Thank you very much for your help.
Best wishes,
Luigi


CODE:


### open plot library
library(lattice)

my.data-structure(list(
   column_1 = 1:120,
   column_2 = structure(c(
 1,2,3,4,5,6,7,8,
 1,2,3,4,5,6,7,8,
 1,2,3,4,5,6,7,8,
 1,2,3,4,5,6,7,8,
 1,2,3,4,5,6,7,8,
 1,2,3,4,5,6,7,8,
 1,2,3,4,5,6,7,8,
 1,2,3,4,5,6,7,8,
 1,2,3,4,5,6,7,8,
 1,2,3,4,5,6,7,8,
 1,2,3,4,5,6,7,8,
 1,2,3,4,5,6,7,8,
 1,2,3,4,5,6,7,8,
 1,2,3,4,5,6,7,8,
 1,2,3,4,5,6,7,8), .Label = c(Unstimulated, ESAT6, CFP10,
Rv3615c, Rv2654, Rv3879, Rv3873, PHA), class = factor),
column_3 = structure(c(
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,
1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,
0,0,0,0,0,0,0,0)),
 column_4 = c(
 
192.0519108,183.6403531,53.46798757,83.60638077,69.60749873,159.4706861,256.
8765622,499.2899303,
 
2170.799076,1411.349719,2759.472348,2098.973397,2164.739515,1288.676574,1611
.486543,6205.229575,
 
870.7424981,465.9967135,191.8962375,864.0937485,2962.693675,1289.259137,2418
.651212,7345.712517,