Hi Noah

All the categories have masked what is going on. I coverted some 
columns to factors and replotted

tab$Label <- sapply(tab$label, pmatch, sort(unique(as.character(tab$label))))
tab$Assign <- as.numeric(sub("[^0-9]+","",as.character(tab$assignment)))

To get a look try

xyplot(freq ~ Assign|Label, tab, groups = method, type = "h", 
drop.unused =T, lwd = c(2,1), scales = list(x= list(relation = 
"free")), as.table = T)

I think for you to resize the panels you need to recode 
tab$assignment so that there are 1:max(tab$assignment) for each panel 
or label - ie there would be 7 categories ie 1:7  in panel 1 and 6 in 
2 ie 1:6 in panel 2.
As it stands now there are few overlapping codes.

  HTH

Duncan

Duncan Mackay
Department of Agronomy and Soil Science
University of New England
Armidale NSW 2351

-----Original Message-----
From: r-help-boun...@r-project.org 
[mailto:r-help-boun...@r-project.org] On Behalf Of Noah Hoffman
Sent: Saturday, 24 August 2013 09:43
To: r-help@r-project.org
Subject: [R] hide unused labels and resize panels in lattice barchart

Hello - I'm stumped on a lattice question. I'll start with my existing code:

library(lattice)
library(latticeExtra)

# no https for read.csv...
tab <- read.csv(pipe('curl -s 
<https://raw.github.com/gist/6323455')>https://raw.github.com/gist/6323455'))

fig <- barchart(assignment ~ freq | label,
                  groups=method,
                  data=tab,
                  scales=list(y=list(relation='free')),
                  auto.key=TRUE,
                  strip = FALSE, strip.left = TRUE,
                  layout=c(1, length(levels(tab$label))),
                  drop.unused.levels=TRUE
                  )
resizePanels(fig)

pdf('plot.pdf', height=17)
plot(fig)
dev.off()

Here's the output: 
<http://cl.ly/image/3B3s3L032I3p>http://cl.ly/image/3B3s3L032I3p

My intention is to produce a plot showing the relative frequency of 
each category in "assignment" conditioned by "label" (with paired 
bars for each value of "method") - but I can't figure out how to 
resize each panel along the y axis and show only categories that have 
corresponding x values in each panel.  Looking at Fig 10.21 in the 
lattice book (
<http://lmdvr.r-forge.r-project.org/figures/figures.html>http://lmdvr.r-forge.r-project.org/figures/figures.html)
 
I thought that
resizePanels() might do the trick, but no luck there.

Any help would be much appreciated.

Thanks a lot,
Noah

                [[alternative HTML version deleted]]

______________________________________________
<mailto:R-help@r-project.org>R-help@r-project.org mailing list
<https://stat.ethz.ch/mailman/listinfo/r-help>https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide 
<http://www.R-project.org/posting-guide.html>http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org 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 via email to