Skip to content

Lattice: Setting Conditioning Panel Order in Trellis Plots

3 messages · Rich Shepard, Duncan Murdoch

#
I've looked in Deepayan Sarkar's book without finding how to specify the
order of conditioning panels in a trellis plot. Here's the issue I'm trying
to resolve:

   Sampling locations along a stream channel are not sequentially numbered.
For example, the panel order for one plot (lower left to upper right, 4
panels per row): SC, SC-1, SC-100, SC-139, SC-140, SC-141, SC-145. SC-2,
SC-3, and SC-50. This is normal collation order, while I need numeric order.

   Is there a way for me to specify the panel order so the display is SC,
SC-1, SC-2, SC-3, SC-50, SC-100, SC-139, SC-140, SC-141, SC-145? If so,
please teach me how to do this.

Rich
#
On 11-12-30 9:56 AM, Rich Shepard wrote:
You don't describe the variable holding those labels.  If it is a factor 
with the levels in the desired order then it should display properly. 
To get that, try something like this (simplified to fewer levels, 
because I'm lazy):

# Make up some sample data:
x <- c("SC",  "SC-1", "SC-100", "SC-2")

# Set the levels in the desired order:

x <- factor(x, levels=c("SC", "SC-1", "SC-2", "SC-100"))

Duncan Murdoch
#
On Fri, 30 Dec 2011, Duncan Murdoch wrote:

            
Duncan,

   Apologies; I did not know what supporting information to provide.

   It's a factor in the data frame, but obviously not in the desired order.
Here's an example of the command:

xyplot(TDS ~ SO4 | site, data = snow.cast, main = 'TDS in Snow Canyon
Creek', ylab = 'Concentration (mg/L)', xlab = 'Sulfate (mg/L)')

   If I correctly understand, I'd first assign the desired sequence to a
variable (x in your example above), the specify that variable as the
conditioning factor in the formula; e.g,,

xyplot(TDS ~ SO4 | x, data = snow.cast, main = 'TDS in Snow Canyon
Creek', ylab = 'Concentration (mg/L)', xlab = 'Sulfate (mg/L)')

   Thanks very much for the insight!

Happy New Year,

Rich