[R] specify xlim for each panel

Deepayan Sarkar deepayan.sarkar at gmail.com
Tue Apr 24 21:25:25 CEST 2007

On 4/24/07, Aimin Yan <aiminy at iastate.edu> wrote:
> I draw dotplot using the following code:
> sd.dotplot<-dotplot(data.47.nmr$om_sd ~ as.factor(data.47.nmr$position)
> |as.factor(data.47.nmr$pr), data = data.47.nmr,layout=c(1,1),
> xlab="Position", xlim=range(data.47.nmr$position),ylab="Sd", main="Changes
> of omega angle in different positions",
> scales = list(x = list(rot = 45)))
> However I get same xlim for each panel,
> Actually xlim is different for each panel, it is based on data.47.nmr$position.
> How can I modify this code so I can deal with the different xlim for each panel

The simplest answer to that depends on your data, so please give a
reproducible example. Hints: try scales = list(x = list(relation =
"free", rot = 45)), and if that doesn't work as intended, consider
reordering the levels of your factor (see ?reorder.factor). Something

    dotplot(om_sd ~ reorder(as.factor(position), pr) | as.factor(pr),
data = <...>

should work.

By the way, you are missing the whole point of having a formula
interface; you can simply do:

sd.dotplot <-
    dotplot(om_sd ~ as.factor(position) | as.factor(pr),
            data = data.47.nmr,

More information about the R-help mailing list