[R] set axis limit in lattice

Duncan Mackay dulcalma at bigpond.com
Tue May 13 02:27:45 CEST 2014


Hi Luigi

Your key code was not included. That’s why I always put the key code with the key argument and the same for trellis.par.get() in panel.settings

Your ratio was a character variable and would not plot

When all else fails I get back to basics eg

str(my.data)
my.data$ratio <- as.numeric(my.data$ratio)
> stripplot(ratio ~ factor(igra)|factor(stimulus,
+  levels = c("a", "b", "c", "d", "e", "f", "g", "h")),
+  group = igra,
+       my.data,
+       hor=F,
+       layout = c(8,1)
+ )

See how things go now

Duncan


-----Original Message-----
From: Luigi Marongiu [mailto:marongiu.luigi at gmail.com] 
Sent: Tuesday, 13 May 2014 02:28
To: Duncan Mackay
Subject: Re: [R] set axis limit in lattice

Dear Duncan,
I believed I have isolated the error in my script: is not actually the
script to be wrong, but simply missing values within the variable I
was analyzing. in the dataset I sent you before I have two numerical
variables: copy and ratio. the first generates the graph exactly as
required, but if i plot the ratios, the segments are not displayed.
is there a way to eliminates the empty values? I tried with a na.rm =
T in the panel.groups = function(x, y, ...) and panel.stripplot(x, y,
...) calls, but without success.
any tip?

Thank you for the nth time
Best regards
Luigi


# code:
my.data<-structure(list(
patient =
 c(
1, 1, 1, 1, 1, 1, 1,
2, 2, 2, 2, 2, 2, 2,
3, 3, 3, 3, 3, 3, 3,
4, 4, 4, 4, 4, 4, 4,
5, 5, 5, 5, 5, 5, 5,
6, 6, 6, 6, 6, 6, 6,
7, 7, 7, 7, 7, 7, 7,
8, 8, 8, 8, 8, 8, 8,
9, 9, 9, 9, 9, 9, 9,
10, 10, 10, 10, 10, 10, 10,
11, 11, 11, 11, 11, 11, 11,
12, 12, 12, 12, 12, 12, 12,
13, 13, 13, 13, 13, 13, 13,
14, 14, 14, 14, 14, 14, 14,
15, 15, 15, 15, 15, 15, 15,
16, 16, 16, 16, 16, 16, 16,
17, 17, 17, 17, 17, 17, 17,
18, 18, 18, 18, 18, 18, 18,
19, 19, 19, 19, 19, 19, 19),
stimulus = structure(
 c(
1, 2, 3, 4, 5, 6, 7,
1, 2, 3, 4, 5, 6, 7,
1, 2, 3, 4, 5, 6, 7,
1, 2, 3, 4, 5, 6, 7,
1, 2, 3, 4, 5, 6, 7,
1, 2, 3, 4, 5, 6, 7,
1, 2, 3, 4, 5, 6, 7,
1, 2, 3, 4, 5, 6, 7,
1, 2, 3, 4, 5, 6, 7,
1, 2, 3, 4, 5, 6, 7,
1, 2, 3, 4, 5, 6, 7,
1, 2, 3, 4, 5, 6, 7,
1, 2, 3, 4, 5, 6, 7,
1, 2, 3, 4, 5, 6, 7,
1, 2, 3, 4, 5, 6, 7,
1, 2, 3, 4, 5, 6, 7,
1, 2, 3, 4, 5, 6, 7,
1, 2, 3, 4, 5, 6, 7,
1, 2, 3, 4, 5, 6, 7), .Label = c("a", "b", "c", "d", "e", "f", "g"),
class = "factor"),
ratio =
 c(
0.5, 3.046, 1.833, "", 0.5,
"", "", 509.5, 991, 689.6, 1285,
683.7, 468.7, 47.08, 4.707,
11.93, 1.194, 0.9422, 1.533,
1.221, 4.201, 1.339, 1.402,
0.8802, 0.7443, 1.074, 1.455,
1.31, "", "", "", "", "", "", "",
1.453, 1.212, 1.114, 1.118,
0.4815, 0.774, 0.6342, "", "",
"", "", "", "", "", 8.534, 2.733,
"", 11.18, 10.41, 0.7532, "",
15.85, 3.287, 1.016, 1.871,
10.55, 0.0271, 1.021, "", "",
"", "", "", "", "", 250.9, 399.1,
959.4, 1.994, 589.2, 5.366,
48.27, 10.32, "", 3.33, "", 1,
"", 1, "", "", "", "", "", "",
"", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", 0.0385,
7.34, 1.283, 1.39, 0.5383, 0.7582,
8.927, 1.11, 2.293, 2.967, 0.5916,
0.6583, 0.6642, 1.741, 2.924,
520.8, 1809, 246.3, 9.509, 149,
2345, "", "", "", "", "", "", 0),
igra = c(
0, 0, 0, 0, 0, 0, 0,
1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1,
0, 0, 0, 0, 0, 0, 0,
1, 1, 1, 1, 1, 1, 1,
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,
1, 1, 1, 1, 1, 1, 1,
0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0,
1, 1, 1, 1, 1, 1, 1,
0, 0, 0, 0, 0, 0, 0),
copy = c(
20.41948227, 12.3610523, 711783.1408,
0, 8.41948261, 0, 19414.73125,
26586.96616, 21069.03039, 55244.5537,
29950.52194, 14191.45894, 4921.598445,
252.8142804, 49.32538755, 17.73442927,
39.27134343, 87.32352071, 16.14534354,
7.865792953, 270.498612, 353.9186557,
120.5907622, 164.5453198, 298.5956386,
316.6322911, 397.5854328, 890.7536693,
19372.09849, 402.4608222, 344.6323822,
0, 289.4324029, 973.6568538, 48.21785613,
28.92271826, 85.70103824, 55.82984865,
96.36313044, 167.3926449, 96.76142763,
329314.8959, 0.297018269, 8.750954723,
0, 0, 123781.3067, 0, 37.70119817,
12.23762742, 9.646257035, 49.22833393,
45.87457312, 0, 24.45326923, 32671.70213,
1585.752121, 1174.13233, 1873.410022,
9580.233901, 56.46155358, 774.397583,
 11786.89182, 30729.7153, 7028.446254,
2163.865049, 5576.189471, 2593.364485,
11324.02438, 13731.67912, 2303.618988,
18332.90754, 19.18572137, 37525.00296,
263.9788119, 2151.347561, 34.37662767,
0, 11.23989372, 0, 0, 0, 0,
3.423728027, 0, 0, 711783.1408,
0, 0, 3.423728027, 37.5844984, 0,
7.467256392, 4.767843998, 0, 7.160960591,
0, 0.950504268, 38.34816271, 571.0440441,
206.1038868, 131.4781753, 1.157851512,
0.843998323, 5.466468742, 291.9564635,
80.73914133, 73.02239621, 64.47806871,
144.3543635, 3167.959757, 945.2201456,
5840.70184, 3455.769481, 1031.511593, 760.265283,
617.9227586, 2138.459304, 0.507950685,
112.2116487, 444.3196672, 118.4640278,
3.217821766, 98.42959451, 1118.368034,
0, 0, 0, 0, 0, 0, 0)),
 row.names = c(NA, -133L),  class = "data.frame")

library(lattice)

# this works
stripplot(copy ~ factor(igra)|factor(stimulus,
levels = c("a", "b", "c", "d", "e", "f", "g", "h")),
group = igra,
my.data,
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="Positivity Plot by stimulation",
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, ...)
{
panel.stripplot(x, y, ..., na.rm = T)
m <- median(y)
panel.segments(x[1]-0.3, m, x[1]+0.3, m)
}
)

# this does not work
stripplot(ratio ~ factor(igra)|factor(stimulus,
 levels = c("a", "b", "c", "d", "e", "f", "g", "h")),
 group = igra,
      my.data,
      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="Positivity Plot by stimulation",
      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, ...)
  {
            panel.stripplot(x, y, ..., na.rm = T)
            m <- median(y)
            panel.segments(x[1]-0.3, m, x[1]+0.3, m)
  }
 )

On Fri, May 9, 2014 at 5:17 AM, Duncan Mackay <dulcalma at bigpond.com> wrote:
> Luigi
>
> I suspect that it is in accessing the correct groups within the panel function
>
> I suggest that printing the values before plotting within the panel function may give you some idea.
>
> Without specific data I cannot suggest anything else
>
> Duncan
>
> -----Original Message-----
> From: Luigi Marongiu [mailto:marongiu.luigi at gmail.com]
> Sent: Wednesday, 7 May 2014 22:37
> To: Duncan Mackay
> Subject: Re: [R] set axis limit in lattice
>
> Dear Duncan,
> thank you for the reply. I have fixed the axis, bu still I don't
> understand why i cannot draw the segments on my real data whereas i
> could on the example when the panel function is quite general. igra is
> the outcome that i rendered as positivity in the example. i also
> change it into numeric values (1/0) to resemble more closely the
> example but still the segments are ignored.
> may i ask you for a tip on the possible causes?
> best regards
> luigi
>
> On Thu, May 1, 2014 at 3:00 AM, Duncan Mackay <dulcalma at bigpond.com> wrote:
>> If you just want to limit the axis just insert as arguments
>> for the x axis
>> xlim = c(min, max),
>> and for the y
>> ylim = c(min,max) ,
>> where min and max correspond to the appropriate min and max  for the x and y axes
>>
>> As for the panel.groups you mention medians where I was using means - if you want medians you will have to amend means to medians
>>
>> Make sure for the groups you have the right mode numeric/ factor ?
>> I do not know what igra is
>>
>> Duncan
>>
>> -----Original Message-----
>> From: Luigi Marongiu [mailto:marongiu.luigi at gmail.com]
>> Sent: Thursday, 1 May 2014 03:54
>> To: Duncan Mackay
>> Subject: Re: [R] set axis limit in lattice
>>
>> Dear Duncan,
>> these solutions are actually splitting the drawing in different panels
>> and the scale=free is giving different limits to each panel. I still
>> need the relation=same but just to input myself the fixed limits of
>> the axis. It should go into the scale argument but i don't know the
>> actual syntax.
>> As for the segments, you were perfectly right, there was a problem
>> with my script so the medians did not match the actual data. Your
>> solution using panel.groups works on the example, but when I copied it
>> to the actual dataframe I am working with it did not work despite the
>> fact of being of quite a general syntax. could you please give a look
>> at the dataframe I have attached and see where I made a mistake in
>> applying your solution? what I wrote is:
>>
>>   my.data.IP10<-subset(my.data, gene=="i" & stimulus != "Unstimulated")
>>
>> stripplot(
>>    my.data.IP10$ratio ~
>> factor(my.data.IP10$igra)|factor(my.data.IP10$stimulus, levels =
>> c("ESAT6","CFP10","Rv3615c", "Rv2654","Rv3879", "Rv3873","PHA")),
>>          my.data,
>>          group = my.data.IP10$igra,
>>          hor=F,
>>         layout = c(7,1),
>>          scales = list(x = list(draw=FALSE)),
>>    jitter.data=TRUE,
>>    pch=c(1,16),
>>    col="black",
>>          ylab=expression(bold("Ratio GOI/RG")),
>>          xlab=expression(bold("Antigen stimulation")),
>>          main="IP10 expression",
>>          par.settings = list(strip.background=list(col="light grey")),
>>              par.strip.text=list(font=2),
>>        key = list(space="top", columns=2, text=list(c("IGRA Negative",
>> "IGRA Positive"), col="black"), points=list(pch=c(1,16),
>> col="black")),
>>
>>  panel = panel.superpose,
>>         panel.groups = function(x, y, group.number, ...) {
>>
>>                         panel.segments(x0= x-0.25, x1=x+0.25,
>> 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, ...)
>>               }
>> )
>>
>>
>> ### Many thanks
>> ### Best regards
>> Luigi
>>
>>
>> On Wed, Apr 30, 2014 at 12:15 AM, Duncan Mackay <dulcalma at bigpond.com> wrote:
>>> Hi Luigi
>>>
>>> This produces plenty of white space for the y axes
>>>
>>> Y<-max(my.data$copy)
>>>
>>> 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")),
>>>                      y= list(relation = "free")),
>>>        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()
>>>   k<-0
>>>   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, ...)
>>>    }
>>>              }
>>>        )
>>> You could limit the y-axis to your levels
>>> 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")),
>>>                      y= list(relation = "free",
>>>                                  limits = list(c(0, max panel 1),
>>>                                                      c(0, max panel 2),
>>>                                                     ...
>>>                                                    c(0, max panel 8)),
>>>       )),
>>>        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()
>>>   k<-0
>>>   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, ...)
>>>    }
>>>              }
>>>        )
>>>
>>> Sorting the stimulation groups shows that some of them can be loosely grouped so reordering the factors
>>>
>>> stripplot(copy ~ factor(positivity)|factor(stimulation, levels = c("PHA","Rv2654","CFP10","Unst.","Rv3615c", "Rv3873","ESAT6", "Rv3879")),
>>>        my.data,
>>>        group = positivity,
>>>        hor=F,
>>>        layout = c(2,4),
>>>        scales = list(x = list(at = c(1,2), labels = c("N","P")),
>>>                      y= list(relation = "free")),
>>>        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()
>>>   k<-0
>>>   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, ...)
>>>    }
>>>              }
>>>        )
>>>
>>> or using panel.groups
>>>
>>> stripplot(copy ~ factor(positivity)|factor(stimulation, levels = c("PHA","Rv2654","CFP10","Unst.","Rv3615c", "Rv3873","ESAT6", "Rv3879")),
>>>        my.data,
>>>        group = positivity,
>>>        hor=F,
>>>        layout = c(2,4),
>>>        scales = list(x = list(at = c(1,2), labels = c("N","P")),
>>>                      y= list(relation = "free")),
>>>        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-0.25, x1=x+0.25, 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, ...)
>>>              }
>>>       )
>>>
>>> Regards
>>>
>>> Duncan Mackay
>>>
>>> -----Original Message-----
>>> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Luigi Marongiu
>>> Sent: Wednesday, 30 April 2014 03:58
>>> To: r-help at r-project.org
>>> Subject: [R] set axis limit in lattice
>>>
>>> Dear all,
>>>
>>> I would like to set the axis of a figure using the max() so to have
>>> more control on the limits of the axis -- this because in the actual
>>> case more independent figures are generated from the same dataframe
>>> and these must have the same axis scale.
>>>
>>> Since the figure is generated using lattice device, the syntax is too
>>> complicated for me: when I place the xlim=c(0,Y) in the arguments —
>>> where Y is obtained using max(data) — there is no result. In basic R
>>> this argument would work virtually in any position.
>>>
>>> Any tip?
>>>
>>> Best regards
>>>
>>> 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("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,
>>>  2767.493803,4796.33016,12292.93705,3864.657567,9380.673835,14886.44683,8457.88646,26050.47191)),
>>> .Names = c("row", "stimulation", "positivity", "copy"), row.names =
>>> c(NA, -120L),
>>>  class = "data.frame")
>>>
>>> key.plot<-list(
>>>   space="top", columns=2,
>>>   text=list(c("Positive", "Negative"), col="black"),
>>>   points=list(pch=c(16,1), col="black"))
>>>
>>> datmeA <- aggregate(copy ~ positivity+stimulation, my.data, median, na.rm = T)
>>>
>>> X<-c(0.7, 1.3, 1.7, 2.3)
>>>
>>> Y<-max(copy)
>>>
>>> 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()
>>>   k<-0
>>>   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, ...)
>>>    }
>>>              }
>>>        )
>>>
>>> ______________________________________________
>>> R-help at 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.
>>>
>>
>



More information about the R-help mailing list