Re: [R] lattice xyplot: how to change the y-axis labels size using yscale.components.subticks on the right side and how to adapt the ticks number

2023-05-31 Thread Laurent Rhelp

I will try to explain in a bit more detail.

1. I want to have the labels on the right with a small size to be able 
to read them

2. I would like not to have the labels on the left
3.  I would like to be able to choose the number of principal ticks for 
every sensor. That is to say the value of n in the call of 
my_yscale.components.subtick. But I have the impression that n is always 
equal to 5.


To change the n number I tried to do this:

my_yscale.components.subticks <- function (lim, ..., n = 5, n2 = n * 5, 
min.n2 = n + 5)

  {
    n1 <- 10
    n2 <- n1*5
    ans <- yscale.components.default(lim = lim, ...,    n  =  n1 )
    ans2 <- yscale.components.default(lim = lim, ...,  n  =  n2 ,
  min.n = min.n2)
  etc...

It works but the n value is the same for all the sensors.

thank you



Le 30/05/2023 à 20:06, Deepayan Sarkar a écrit :

Thanks for the reproducible example. Could you explain what you want
in a bit more detail? Does the following do more or less what you
want, except that the labels are on the left instead of right?

gr <-
 xyplot(value ~ tindexTOP | sensor
  , data = df_rhelp
  , ylab = " "
  , xlab = list("Time (s)", font=9)
  , main = "test yscale.components with axis"
  , subset = sensor %in% paste0("sensor",1:8)
  , layout = c(1,8)
  , between = list(y = 0.5),
  , scales = list(y = list(relation = "free", cex = 0.3, rot = 0)
, x = list(relation = "same", axs = "i",
   rot = 45, cex = 0.3))
  , type = c("l","g")
  , yscale.components = my_yscale.components.subticks
## , xscale.components = xscale.components.subticks
  , strip = F
  , strip.left = strip.custom(
par.strip.text = list(font=3, cex = 0.5,col="red",lines=3)
)
  , par.strip.text = list(font=3, cex = 0.5,col="red",lines=2)
  , par.settings = list(plot.line  = list(col = "black")
  , strip.background=list(col="transparent")
  , layout.widths = list(axis.key.padding = 5)
))

If you want the same labels on the right as well, you will just need
to uncomment the line

ans$right <- TRUE

in your my_yscale.components.subticks function.

-Deepayan

On Tue, May 30, 2023 at 12:39 AM Laurent Rhelp  wrote:

Dear R-Help-list,

 I want to display many sensors on the same page so I have to adapt
the size of the y-axis labels and I woul like to adapt the number of
ticks according to the sensor. I use the yscale.components argument with
the function yscale.components.subticks: see the code below.

In order to change the size labels on the right I tried to add the line
ans$left$labels$cex <- 0.3 in yscale.components.subticks but it doesn't
work. I try to put cex = 0.3 in the scale argument for the y list but it
doesn't work too.

And since the numeric ranges of sensors are different I would like to
adapt the ticks number for every sensor. But I didn't undestand how to
pass the value of the n argument at the yscale.components function and
how I can use this function according to the current panel.

Thank you

Best regards

Laurent


o<-->o

The data:

df_rhelp <- structure(list(tindexTOP = c(4.76837158203125e-07,
4.76837158203125e-07,
4.76837158203125e-07, 4.76837158203125e-07, 4.76837158203125e-07,
4.76837158203125e-07, 4.76837158203125e-07, 4.76837158203125e-07,
4.76837158203125e-07, 2.86102294921875e-06, 2.86102294921875e-06,
2.86102294921875e-06, 2.86102294921875e-06, 2.86102294921875e-06,
2.86102294921875e-06, 2.86102294921875e-06, 2.86102294921875e-06,
2.86102294921875e-06, 5.48362731933594e-06, 5.48362731933594e-06,
5.48362731933594e-06, 5.48362731933594e-06, 5.48362731933594e-06,
5.48362731933594e-06, 5.48362731933594e-06, 5.48362731933594e-06,
5.48362731933594e-06, 7.86781311035156e-06, 7.86781311035156e-06,
7.86781311035156e-06, 7.86781311035156e-06, 7.86781311035156e-06,
7.86781311035156e-06, 7.86781311035156e-06, 7.86781311035156e-06,
7.86781311035156e-06, 1.04904174804688e-05, 1.04904174804688e-05,
1.04904174804688e-05, 1.04904174804688e-05, 1.04904174804688e-05,
1.04904174804688e-05, 1.04904174804688e-05, 1.04904174804688e-05,
1.04904174804688e-05, 1.28746032714844e-05, 1.28746032714844e-05,
1.28746032714844e-05, 1.28746032714844e-05, 1.28746032714844e-05,
1.28746032714844e-05, 1.28746032714844e-05, 1.28746032714844e-05,
1.28746032714844e-05, 1.54972076416016e-05, 1.54972076416016e-05,
1.54972076416016e-05, 1.54972076416016e-05, 1.54972076416016e-05,
1.54972076416016e-05, 1.54972076416016e-05, 1.54972076416016e-05,
1.54972076416016e-05, 1.78813934326172e-05, 1.78813934326172e-05,
1.78813934326172e-05, 1.78813934326172e-05, 1.78813934326172e-05,
1.78813934326172e-05, 1.78813934326172e-05, 

Re: [R] lattice xyplot: how to change the y-axis labels size using yscale.components.subticks on the right side and how to adapt the ticks number

2023-05-30 Thread Deepayan Sarkar
Thanks for the reproducible example. Could you explain what you want
in a bit more detail? Does the following do more or less what you
want, except that the labels are on the left instead of right?

gr <-
xyplot(value ~ tindexTOP | sensor
 , data = df_rhelp
 , ylab = " "
 , xlab = list("Time (s)", font=9)
 , main = "test yscale.components with axis"
 , subset = sensor %in% paste0("sensor",1:8)
 , layout = c(1,8)
 , between = list(y = 0.5),
 , scales = list(y = list(relation = "free", cex = 0.3, rot = 0)
   , x = list(relation = "same", axs = "i",
  rot = 45, cex = 0.3))
 , type = c("l","g")
 , yscale.components = my_yscale.components.subticks
   ## , xscale.components = xscale.components.subticks
 , strip = F
 , strip.left = strip.custom(
   par.strip.text = list(font=3, cex = 0.5,col="red",lines=3)
   )
 , par.strip.text = list(font=3, cex = 0.5,col="red",lines=2)
 , par.settings = list(plot.line  = list(col = "black")
 , strip.background=list(col="transparent")
 , layout.widths = list(axis.key.padding = 5)
   ))

If you want the same labels on the right as well, you will just need
to uncomment the line

   ans$right <- TRUE

in your my_yscale.components.subticks function.

-Deepayan

On Tue, May 30, 2023 at 12:39 AM Laurent Rhelp  wrote:
>
> Dear R-Help-list,
>
> I want to display many sensors on the same page so I have to adapt
> the size of the y-axis labels and I woul like to adapt the number of
> ticks according to the sensor. I use the yscale.components argument with
> the function yscale.components.subticks: see the code below.
>
> In order to change the size labels on the right I tried to add the line
> ans$left$labels$cex <- 0.3 in yscale.components.subticks but it doesn't
> work. I try to put cex = 0.3 in the scale argument for the y list but it
> doesn't work too.
>
> And since the numeric ranges of sensors are different I would like to
> adapt the ticks number for every sensor. But I didn't undestand how to
> pass the value of the n argument at the yscale.components function and
> how I can use this function according to the current panel.
>
> Thank you
>
> Best regards
>
> Laurent
>
>
> o<-->o
>
> The data:
>
> df_rhelp <- structure(list(tindexTOP = c(4.76837158203125e-07,
> 4.76837158203125e-07,
> 4.76837158203125e-07, 4.76837158203125e-07, 4.76837158203125e-07,
> 4.76837158203125e-07, 4.76837158203125e-07, 4.76837158203125e-07,
> 4.76837158203125e-07, 2.86102294921875e-06, 2.86102294921875e-06,
> 2.86102294921875e-06, 2.86102294921875e-06, 2.86102294921875e-06,
> 2.86102294921875e-06, 2.86102294921875e-06, 2.86102294921875e-06,
> 2.86102294921875e-06, 5.48362731933594e-06, 5.48362731933594e-06,
> 5.48362731933594e-06, 5.48362731933594e-06, 5.48362731933594e-06,
> 5.48362731933594e-06, 5.48362731933594e-06, 5.48362731933594e-06,
> 5.48362731933594e-06, 7.86781311035156e-06, 7.86781311035156e-06,
> 7.86781311035156e-06, 7.86781311035156e-06, 7.86781311035156e-06,
> 7.86781311035156e-06, 7.86781311035156e-06, 7.86781311035156e-06,
> 7.86781311035156e-06, 1.04904174804688e-05, 1.04904174804688e-05,
> 1.04904174804688e-05, 1.04904174804688e-05, 1.04904174804688e-05,
> 1.04904174804688e-05, 1.04904174804688e-05, 1.04904174804688e-05,
> 1.04904174804688e-05, 1.28746032714844e-05, 1.28746032714844e-05,
> 1.28746032714844e-05, 1.28746032714844e-05, 1.28746032714844e-05,
> 1.28746032714844e-05, 1.28746032714844e-05, 1.28746032714844e-05,
> 1.28746032714844e-05, 1.54972076416016e-05, 1.54972076416016e-05,
> 1.54972076416016e-05, 1.54972076416016e-05, 1.54972076416016e-05,
> 1.54972076416016e-05, 1.54972076416016e-05, 1.54972076416016e-05,
> 1.54972076416016e-05, 1.78813934326172e-05, 1.78813934326172e-05,
> 1.78813934326172e-05, 1.78813934326172e-05, 1.78813934326172e-05,
> 1.78813934326172e-05, 1.78813934326172e-05, 1.78813934326172e-05,
> 1.78813934326172e-05, 2.05039978027344e-05, 2.05039978027344e-05,
> 2.05039978027344e-05, 2.05039978027344e-05, 2.05039978027344e-05,
> 2.05039978027344e-05, 2.05039978027344e-05, 2.05039978027344e-05,
> 2.05039978027344e-05, 2.288818359375e-05, 2.288818359375e-05,
> 2.288818359375e-05, 2.288818359375e-05, 2.288818359375e-05,
> 2.288818359375e-05,
> 2.288818359375e-05, 2.288818359375e-05, 2.288818359375e-05,
> 2.55107879638672e-05,
> 2.55107879638672e-05, 2.55107879638672e-05, 2.55107879638672e-05,
> 2.55107879638672e-05, 2.55107879638672e-05, 2.55107879638672e-05,
> 2.55107879638672e-05, 2.55107879638672e-05, 2.78949737548828e-05
> ), sensor = structure(c(3L, 4L, 5L, 6L, 7L, 8L, 9L, 1L, 2L, 3L,
> 4L, 5L, 6L, 7L, 8L, 9L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 1L,
> 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 

[R] lattice xyplot: how to change the y-axis labels size using yscale.components.subticks on the right side and how to adapt the ticks number

2023-05-29 Thread Laurent Rhelp

Dear R-Help-list,

   I want to display many sensors on the same page so I have to adapt 
the size of the y-axis labels and I woul like to adapt the number of 
ticks according to the sensor. I use the yscale.components argument with 
the function yscale.components.subticks: see the code below.


In order to change the size labels on the right I tried to add the line 
ans$left$labels$cex <- 0.3 in yscale.components.subticks but it doesn't 
work. I try to put cex = 0.3 in the scale argument for the y list but it 
doesn't work too.


And since the numeric ranges of sensors are different I would like to 
adapt the ticks number for every sensor. But I didn't undestand how to 
pass the value of the n argument at the yscale.components function and 
how I can use this function according to the current panel.


Thank you

Best regards

Laurent


o<-->o

The data:

df_rhelp <- structure(list(tindexTOP = c(4.76837158203125e-07, 
4.76837158203125e-07,

4.76837158203125e-07, 4.76837158203125e-07, 4.76837158203125e-07,
4.76837158203125e-07, 4.76837158203125e-07, 4.76837158203125e-07,
4.76837158203125e-07, 2.86102294921875e-06, 2.86102294921875e-06,
2.86102294921875e-06, 2.86102294921875e-06, 2.86102294921875e-06,
2.86102294921875e-06, 2.86102294921875e-06, 2.86102294921875e-06,
2.86102294921875e-06, 5.48362731933594e-06, 5.48362731933594e-06,
5.48362731933594e-06, 5.48362731933594e-06, 5.48362731933594e-06,
5.48362731933594e-06, 5.48362731933594e-06, 5.48362731933594e-06,
5.48362731933594e-06, 7.86781311035156e-06, 7.86781311035156e-06,
7.86781311035156e-06, 7.86781311035156e-06, 7.86781311035156e-06,
7.86781311035156e-06, 7.86781311035156e-06, 7.86781311035156e-06,
7.86781311035156e-06, 1.04904174804688e-05, 1.04904174804688e-05,
1.04904174804688e-05, 1.04904174804688e-05, 1.04904174804688e-05,
1.04904174804688e-05, 1.04904174804688e-05, 1.04904174804688e-05,
1.04904174804688e-05, 1.28746032714844e-05, 1.28746032714844e-05,
1.28746032714844e-05, 1.28746032714844e-05, 1.28746032714844e-05,
1.28746032714844e-05, 1.28746032714844e-05, 1.28746032714844e-05,
1.28746032714844e-05, 1.54972076416016e-05, 1.54972076416016e-05,
1.54972076416016e-05, 1.54972076416016e-05, 1.54972076416016e-05,
1.54972076416016e-05, 1.54972076416016e-05, 1.54972076416016e-05,
1.54972076416016e-05, 1.78813934326172e-05, 1.78813934326172e-05,
1.78813934326172e-05, 1.78813934326172e-05, 1.78813934326172e-05,
1.78813934326172e-05, 1.78813934326172e-05, 1.78813934326172e-05,
1.78813934326172e-05, 2.05039978027344e-05, 2.05039978027344e-05,
2.05039978027344e-05, 2.05039978027344e-05, 2.05039978027344e-05,
2.05039978027344e-05, 2.05039978027344e-05, 2.05039978027344e-05,
2.05039978027344e-05, 2.288818359375e-05, 2.288818359375e-05,
2.288818359375e-05, 2.288818359375e-05, 2.288818359375e-05, 
2.288818359375e-05,
2.288818359375e-05, 2.288818359375e-05, 2.288818359375e-05, 
2.55107879638672e-05,

2.55107879638672e-05, 2.55107879638672e-05, 2.55107879638672e-05,
2.55107879638672e-05, 2.55107879638672e-05, 2.55107879638672e-05,
2.55107879638672e-05, 2.55107879638672e-05, 2.78949737548828e-05
), sensor = structure(c(3L, 4L, 5L, 6L, 7L, 8L, 9L, 1L, 2L, 3L,
4L, 5L, 6L, 7L, 8L, 9L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 1L,
2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L,
9L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 1L, 2L, 3L, 4L, 5L, 6L,
7L, 8L, 9L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 1L, 2L, 3L, 4L,
5L, 6L, 7L, 8L, 9L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 1L, 2L,
3L, 4L, 5L, 6L, 7L, 8L, 9L, 1L, 2L, 3L), levels = c("sensor1",
"sensor2", "sensor3", "sensor4", "sensor5", "sensor6", "sensor7",
"sensor8", "sensor9"), class = "factor"), value = c(-0.0470466909098229,
-0.00706818838871735, 161.436801895656, -172.78672402378, 
-79.9361479857483,

-0.00891825113687091, -0.0448694697768801, 0.712425108966963,
0.401695579543726, -0.00853561853384195, 0.00227566229773253,
161.583962803598, -172.786724022067, -79.8239603415978, 
-0.00977019791023207,
-0.0456647729895611, -0.13262603339186, -1.42342494912657, 
0.0361391588361329,

0.0101823004079, 161.752781180395, -172.786724020224, -79.47940948,
-0.00833297732602559, -0.0452567494314687, -0.345867818702583,
-0.445302124137744, 0.0740098049592515, 0.00668399483148732,
161.820662102699, -172.786724020131, -79.0099113997788, 
-0.0096576618169,
-0.0450868234218926, 0.438855203334293, 1.65859497904806, 
0.0937767405962466,

0.00523329310606791, 161.832971211745, -172.786724019897, -78.53801857597,
-0.00944050307772246, -0.0451963808453651, 0.874052460245523,
1.27714958276318, 0.080325071018673, 0.0105218297802455, 161.828614569151,
-172.786724026001, -78.1829114611251, -0.0096485992190361, 
-0.045410374886218,
0.213898316321324, -0.93396499839784, 0.0415044547581841, 
0.0116075320692717,
161.80458844672, -172.786724021518, -78.0549456280623, 
-0.00891923753973763,
-0.045981616786497, -0.41157010119221, -1.18416730074984,