Lattice levelplot- remove unused levels per panel

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

Lattice levelplot- remove unused levels per panel

ronny
Hi,

I am using levelplot, and would like remove from each panel (condition) its unused x levels.
e.g.
Remove from panel vs=1 the cyl level=8.
data(mtcars)
levelplot(mpg~factor(cyl)*factor(gear)|factor(vs))

Thanks for your help,
Ronny
Reply | Threaded
Open this post in threaded view
|

Re: Lattice levelplot- remove unused levels per panel

ilai-2
On Sun, Jan 20, 2013 at 1:59 AM, ronny <[hidden email]> wrote:

> Hi,
>
> I am using levelplot, and would like remove from each panel (condition) its
> unused x levels.
>

Uneven scales on categorical axes lead to distortion and a miss
representation (as in your example - the area for levels 4,6 in vs1 will be
bigger than for vs0). In short, don't do it. IMO a solution such as
levelplot(mpg ~ factor(cyl) * factor(gear) | factor(vs) , mtcars,
par.settings=list(panel.background=list(col='grey')))

is much better. Note, your request could make sense for some continuous
variables, so if you insist you could always
levelplot(mpg ~ as.numeric(cyl) * factor(gear) | factor(vs) , mtcars,
scales=list(x=list(relation='free')))

HTH


> e.g.
> Remove from panel vs=1 the cyl level=8.
> data(mtcars)
> levelplot(mpg~factor(cyl)*factor(gear)|factor(vs))
>
> Thanks for your help,
> Ronny
>
>
>
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/Lattice-levelplot-remove-unused-levels-per-panel-tp4656087.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> [hidden email] 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.
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Lattice levelplot- remove unused levels per panel

Richard M. Heiberger
In reply to this post by ronny
require(lattice)
require(latticeExtra)
data(mtcars)
mt2 <- mtcars
mt2$vs <- factor(mtcars$vs)
mt2$cyl <- factor(mtcars$cyl)
mt2$gear <- factor(mtcars$gear)

lp2 <- levelplot(mpg ~ cyl*gear | vs, data=mt2,
                 strip=strip.custom(strip.names=c(TRUE,TRUE)),
                 scales=list(x=list(
                               relation="free",
                               limits=list(c("2","4","6"), c("2","4")))))
update(lp2, main="distorted x scale, hence distorted areas")
lp2r <- resizePanels(lp2, w=c(3,2))
update(lp2r, main="resized x scale, hence areas are consistent")


On Sun, Jan 20, 2013 at 3:59 AM, ronny <[hidden email]> wrote:

> Hi,
>
> I am using levelplot, and would like remove from each panel (condition) its
> unused x levels.
> e.g.
> Remove from panel vs=1 the cyl level=8.
> data(mtcars)
> levelplot(mpg~factor(cyl)*factor(gear)|factor(vs))
>
> Thanks for your help,
> Ronny
>
>
>
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/Lattice-levelplot-remove-unused-levels-per-panel-tp4656087.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> [hidden email] 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.
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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.