Stratifying data with xyplot

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Stratifying data with xyplot

Sebastien Bihorel
Hi,

I am a big user/fan of the lattice package for plotting. As far as I know, lattice only offers one method to stratify data within a xyplot panel, using the groups arguments.
A contrario, the ggplot package allow users to use different variables for coloring, setting the symbols, the line types or the size of symbols. This frequently comes handy.
My question is whether any work has been done in the lattice ecosystem to reproduce this functionality? If so, I would greatly appreciate any pointers to the appropriate package documentation.

Thank you

Sebastien

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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.
Reply | Threaded
Open this post in threaded view
|

Re: Stratifying data with xyplot

Kevin Wright-5
See the examples here:
https://www.stat.ubc.ca/~jenny/STAT545A/block10_latticeNittyGritty.html


On Mon, Mar 11, 2019 at 2:26 PM Sebastien Bihorel <
[hidden email]> wrote:

> Hi,
>
> I am a big user/fan of the lattice package for plotting. As far as I know,
> lattice only offers one method to stratify data within a xyplot panel,
> using the groups arguments.
> A contrario, the ggplot package allow users to use different variables for
> coloring, setting the symbols, the line types or the size of symbols. This
> frequently comes handy.
> My question is whether any work has been done in the lattice ecosystem to
> reproduce this functionality? If so, I would greatly appreciate any
> pointers to the appropriate package documentation.
>
> Thank you
>
> Sebastien
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> 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.
>


--
Kevin Wright

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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.
Reply | Threaded
Open this post in threaded view
|

Re: Stratifying data with xyplot

Deepayan Sarkar
On Tue, Mar 12, 2019 at 2:28 AM Kevin Wright <[hidden email]> wrote:
>
> See the examples here:
> https://www.stat.ubc.ca/~jenny/STAT545A/block10_latticeNittyGritty.html

Excellent reference. The only improvement I could think of is to abuse
the non-standard evaluation of 'groups' to avoid repeating the name of
the dataset, which would go something like

xyplot(lifeExp ~ gdpPercap | factor(year), yDat, aspect = 2/3,
       grid = TRUE, scales = list(x = list(log = 10, equispaced.log = FALSE)),
       col = jDarkGray, pch = jPch,
       groups = list(cex = sqrt(pop/pi) / jCexDivisor,
                     fill = color),
       panel = function(x, y, ..., groups, subscripts) {
           panel.xyplot(x, y,
                        cex = groups$cex[subscripts],
                        fill = groups$fill[subscripts], ...)
         })

Unfortunately, this doesn't work because prepanel.default.xyplot()
tries to be too smart and assumes that 'groups' is a factor. A
workaround is to override the default prepanel function; e.g.,

lattice.options(prepanel.default.xyplot =
                function(x, y, ...) list(xlim = extendrange(range(x)),
                                         ylim = extendrange(range(y))))

I will try to fix prepanel.default.xyplot() for the next update of lattice.

-Deepayan


>
> On Mon, Mar 11, 2019 at 2:26 PM Sebastien Bihorel <
> [hidden email]> wrote:
>
> > Hi,
> >
> > I am a big user/fan of the lattice package for plotting. As far as I know,
> > lattice only offers one method to stratify data within a xyplot panel,
> > using the groups arguments.
> > A contrario, the ggplot package allow users to use different variables for
> > coloring, setting the symbols, the line types or the size of symbols. This
> > frequently comes handy.
> > My question is whether any work has been done in the lattice ecosystem to
> > reproduce this functionality? If so, I would greatly appreciate any
> > pointers to the appropriate package documentation.
> >
> > Thank you
> >
> > Sebastien
> >
> > ______________________________________________
> > [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> > 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.
> >
>
>
> --
> Kevin Wright
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> 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.

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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.