Hi Duncan, Thanks for the reply - my apologies: my example data set was definitely overly complex, and the labels too abstract. I'd really like to provide labels for the assignments on the axis ("species" in the new example below), and I'm not sure how I could accomplish this using your approach. Hopefully this simplified example illustrates the problem (and motivation for the plot) more clearly. Note that "labels" now correspond to specimens and "assignments" to species to make things a bit less abstract.
tab <- read.csv(textConnection( 'label,method,assignment,freq specimen1,A,species1,0.4 specimen1,A,species2,0.6 specimen1,B,species1,0.25 specimen1,B,species2,0.3 specimen2,A,species3,0.3 specimen2,A,species4,0.3 specimen2,A,species5,0.4 specimen2,B,species2,0.2 specimen2,B,species3,0.2 specimen2,B,species4,0.3 specimen2,B,species5,0.3')) 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 ) fig <- resizePanels(fig) plot(fig) Here, despite using resizePanels(), the panels for specimen1 and specimen2 occupy the same amount of vertical space, and the width of the bars are scaled proportionally to the number of species. I'd like to have specimen1 occupy half the vertical space, and for all bars in the plot to be the same width. Thanks again, Noah On Sun, Aug 25, 2013 at 6:47 AM, Duncan Mackay <mac...@northnet.com.au>wrote: > 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<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')) > > 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 > > 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) 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]] > > ______________________________________________ > 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. > [[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.