Can I use shingles from lattice in ggplot2 in R

2020-08-24 17:46发布

问题:

It is possible to use the shingles to define specific ranges in ggplot2. As far as i understand shingles are a way to generate groups. Can we create such shingles and use them in ggplot2 facet_grid to obtain graphs?

回答1:

Following up from the comments, ggplot can't draw shingles (in the way lattice draws shingles with special indicators in the strip) and by default doesn't have a means of producing the overlapping groups.

However, I cam across this excellent PDF document which aims to produce a gpplot2 version of every figure in Depayan's excellent Lattice book (Lattice: Multivariate Data Visualization with R).

Page 31 contains a custom function fn() which replicates the behaviour of equal.count(), as far as I can tell, to provide the correct data structure to plot with overlapping shingles. The PDF contains plenty of examples of "shingles" in ggplot that you can play with.

So not sure if this answers the Q - but at least it appears one can fudge ggplot into producing plots that use the shingle concept.