s-news
[Top] [All Lists]

[S] Re: x axis limits on barchart

To: s-news@wubios.wustl.edu
Subject: [S] Re: x axis limits on barchart
From: Douglas Bates <bates@stat.wisc.edu>
Date: 26 May 1998 09:48:33 -0500
In-reply-to: Douglas Bates's message of 25 May 1998 22:00:45 -0500
References: <6rsolxka76.fsf@verdi.stat.wisc.edu>
Sender: owner-s-news@wubios.wustl.edu
Douglas Bates <bates@stat.wisc.edu> writes:

> I was using barchart today to prepare some graphs for a paper when I
> noticed that the size of the bars was misleading because the bars did
> not start at zero.  The data I was plotting looked like
> 
>  tiger <- data.frame( proportion = c(9.5, 8.8, 3.1, 1.7, 1.2, 0.1), 
>           activity = c("Sleeping", "Pacing", "Feeding", "Grooming", 
>                        "Vocalizing", "Hunting"))
>  barchart( activity ~ proportion, data = tiger )

I apologize for replying to my own query but Bill Venables was kind
enough to remind me that I had already solved this problem in another
context.  The solution is to specify a "scales" argument to the
barchart call and within the x-axis scales list use "axs", not "xaxs"
as I was trying to do.

S> tiger <- data.frame( proportion = c(9.5, 8.8, 3.1, 1.7, 1.2, 0.1),activity
+ = c("Sleeping", "Pacing", "Feeding", "Grooming", "Vocalizing", "Hunting"))
S> tiger$activity <- factor(tiger$activity, levels = unique(tiger$activity))
S> barchart( activity ~ proportion, data = tiger, 
+   scales = list(x = list(axs = "i")), xlim = c(0,10))

That produces a bar chart with the "Sleeping" bar on the bottom and
the "Hunting" bar on the top.  If, like me, you prefer to reverse them
so it looks like a Pareto chart, you can use

S> tiger$activity <- ordered(tiger$activity, levels = 
rev(levels(tiger$activity)))
S> barchart( activity ~ proportion, data = tiger, 
+   scales = list(x = list(axs = "i")), xlim = c(0,10))
-----------------------------------------------------------------------
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>