Re: [R] Attempting to sync x-axis labels with grid lines in lattice bwplot

From: Deepayan Sarkar <deepayan.sarkar_at_gmail.com>
Date: Mon, 21 Apr 2008 15:31:50 -0700

On 4/20/08, Mark Coletti <mcoletti_at_gmail.com> wrote:
> I have created a lattice bwplot that suffers from axis label
> overplotting. The box plot contains grid lines, and I thought that
> only plotting the labels for corresponding vertical grid lines would
> not only cure the overplotting but also be more aesthetically
> pleasing. Unfortunately hours of poring over manuals, documentations,
> mailing list archives, and other R-related text hasn't helped.
>
> This following is the plot:
>
> http://www.lychnobite.org/images/bsf.png
>
> As you can see, the x axis labels are a mess. :(
>
> This is the code I used to generate the plot:
>
> bsf.plot = bwplot( fitness ~ Gen | Crossover * Rules,
> data = bsf.df,
> panel = function(...) {
> panel.grid(v = -10, h = -1)
> panel.bwplot(...)
>
> # cribbed some lines from lattice grid function
> limits <- current.panel.limits()
> print( limits$xlim )
>
> # maybe add x axis plotting here? ... and suppress it elsewhere?
>
> },
> subset = Gen %in% filtered.gen, # mask for plotting only some generations
> par.settings = list(plot.symbol = list(pch = 20)), # dots for outliers
> pch="|", # want median lines not dot
> fill="lightgray", # gray stands out more
> xlab="Generations",
> main = "Best so far" )
>
> I suspect that I'll have to use "at" within "scale" -- but where to
> get the grid line coordinates? As seen above, I cut-n-pasted some of
> the source from "panel.grid", but then realized that there seemed to
> be no way to get that information to the "scale/at" parameter.

A factor such as Gen here would get converted to numeric values using as.numeric() before plotting, so you can infer the 'at' values from that. In other words, the level "0" gets plotted as 1, "10" as 2, and so on.

-Deepayan



R-help_at_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. Received on Mon 21 Apr 2008 - 22:34:43 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 21 Apr 2008 - 23:30:30 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive