Kevin Wright
2007-Jul-26 03:12 UTC
[R] How to auto-scale cex of y-axis labels in lattice dotplot?
When I create a dotplot in lattice, I frequently observe overplotting of the labels along the vertical axis. On my screen, this illustrates overplotting of the letters: windows() reps=6 dat=data.frame(let=rep(letters,each=reps), grp=rep(1:reps, 26), y=runif(26*reps)) dotplot(let~y|grp, dat) Is there a way to automatically scale the labels so that they are not over-plotted? I currently do something like this: Calculate or guess the number of panel rows: NumPanelRows cexLab <- min(1, .9*par()$pin[2]/ (nlevels(dat$let)*NumPanelRows*strheight("A",units="in"))) dotplot(..., scales=list(y=list(cex=cexLab)) Is there an easier way? Is there a function that I can call which calculates the layout of the panels that will be used in the dotplot? Any tips will be appreciated. K Wright
Deepayan Sarkar
2007-Jul-26 19:53 UTC
[R] How to auto-scale cex of y-axis labels in lattice dotplot?
On 7/25/07, Kevin Wright <kw.statr at gmail.com> wrote:> When I create a dotplot in lattice, I frequently observe overplotting > of the labels along the vertical axis. On my screen, this illustrates > overplotting of the letters: > > windows() > reps=6 > dat=data.frame(let=rep(letters,each=reps), grp=rep(1:reps, 26), > y=runif(26*reps)) > dotplot(let~y|grp, dat) > > Is there a way to automatically scale the labels so that they are not > over-plotted?Not that I can think of.> I currently do something like this: > Calculate or guess the number of panel rows: NumPanelRows > cexLab <- min(1, .9*par()$pin[2]/ > (nlevels(dat$let)*NumPanelRows*strheight("A",units="in"))) > dotplot(..., scales=list(y=list(cex=cexLab)) > > Is there an easier way? > > Is there a function that I can call which calculates the layout of the > panels that will be used in the dotplot?Not really. The eventual layout is calculated inside print.trellis as follows (where 'x' is the "trellis" object being plotted): panel.layout <- compute.layout(x$layout, dim(x), skip = x$skip) [...] if (panel.layout[1] == 0) { ddim <- par("din") device.aspect <- ddim[2] / ddim[1] panel.aspect <- panel.height[[1]] / panel.width[[1]] plots.per.page <- panel.layout[2] m <- max (1, round(sqrt(panel.layout[2] * device.aspect / panel.aspect))) n <- ceiling(plots.per.page/m) m <- ceiling(plots.per.page/n) panel.layout[1] <- n panel.layout[2] <- m } -Deepayan
Seemingly Similar Threads
- dotplot/Dotplot: connecting points within factor level across time
- [lattice] lines for stripplot (like dotplot) or jitter for dotplot?
- dotplot: character size of labels (PR#816)
- make a lattice dotplot with symbol size proportional to a variable in the plotted dataframe
- make a lattice dotplot with symbol size proportional to a variable in the plotted dataframe