s-news
[Top] [All Lists]

[S] Reordering labels in a panel of dotplots

To: S-Plus message <s-news@wubios.wustl.edu>
Subject: [S] Reordering labels in a panel of dotplots
From: Renaud Lancelot <lancelot@telecomplus.sn>
Date: Thu, 22 Apr 1999 07:59:07 +0100
Sender: owner-s-news@wubios.wustl.edu
Dear S+ users,

I want to plot a panel of dotplots to describe 8 mortality rates in 3
animal categories. The patterns are rather different for the 3 animal
categories, so I want the diseases to be ordered by mortality rates for
each animal category. Here is the dataset:

eric1 <- data.frame(
        type = c(rep("Poulets de chair", 8), rep("Poulettes", 8), rep("Poules
pondeuses", 8)),
        maladie = rep(c("Newcastle", "Gumboro", "Marek", "Salmonellose",
"Colibacillose", "MRC", "Coccidiose", "Autres"), 3),
        mort = c(27, 23, 0, 7.5, 4.8, 15, 3.5, 7, 25, 10, 13, 13, 2, 1, 1.5, 1,
8, 0, 17, 3.5, 1, 1.5, 1.5, 1.2))

and here is what I tried (among many others !):

dotplot(maladie ~ mort | type,
        data = eric1,
        layout = c(1,3),
        aspect = 0.5,
        between = list(y = 0.5),
        strip = function(...) strip.default(..., style = 1),
        xlab = "Taux de mortalité (%)", ylab = "Maladie", 
        panel = function(x, y){
                y <- reorder.factor(factor(y), x, mean)    ### only one value 
per mean
!
                panel.dotplot(as.numeric(x), as.numeric(y))
        })

The plots are correctly displayed, but the disease labels are in a wrong
order (same order for each plot). Is there a simple way to overcome this
problem ?

NB: I could get a correct result when drawing a single unconditional
dotplot on each subset defined by the animal categories, and combining
the plots (gr1, gr21 and gr3) using:
print(gr1, split = c(1,3,1,3), more = T)
print(gr2, split = c(1,2,1,3), more = T)
print(gr3, split = c(1,1,1,3), more = F)
but the resulting graph is awful.

Many thanks in advance,

Renaud

-- 
Renaud Lancelot
ISRA-LNERV
BP 2057 Dakar-Hann
Senegal

tel     (221) 832 49 02
fax     (221) 821 18 79
email   renaud.lancelot@cirad.fr
-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu.  To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message:  unsubscribe s-news

<Prev in Thread] Current Thread [Next in Thread>
  • [S] Reordering labels in a panel of dotplots, Renaud Lancelot <=