Skip to content
Prev 393690 / 398503 Next

lattice xyplot: trouble about the use of yscale.components to start the yscale from zero

On Sun, Jan 22, 2023 at 6:48 PM Laurent Rhelp <LaurentRHelp at free.fr> wrote:

            
You have mistyped

  ans$left$ticks$at <- tick.at

as

  ans$left$tick$at <- tick.at

You might think that partial matching will help you, but partial matching
doesn't work for assignment (for obvious reasons). Consider
List of 2
 $ ticks:List of 1
  ..$ at: int [1:10] 1 2 3 4 5 6 7 8 9 10
 $ tick :List of 1
  ..$ at: chr "bar"

I don't know if there is a good argument for this assignment to work at all
(other than that NULL and an empty list are conceptually equivalent), but
it is what it is.

This is why I tend to set options(warnPartialMatchDollar = TRUE). In this
case it would give you an inaccurate warning, but at least it will give you
a warning.

As for the range of the scales, these are determined by 'ylim' and
'prepanel', so you would need to specify one of these.

As you are using scales$axs = "i", you can simply provide ylim = c(0, NA),
which forces the lower limit to 0, and lets the upper limit be decided as
usual.

For finer control, you can specify a prepanel function, e.g.,

prepanel = function(x, y, ...) list(ylim = c(0, max(y)))

Hope this helps,

Best,
-Deepayan