s-news
[Top] [All Lists]

Re: [S] Days of week as tick labels

To: Allan Reiffman <allanr@gurunet.com>
Subject: Re: [S] Days of week as tick labels
From: Prof Brian D Ripley <ripley@stats.ox.ac.uk>
Date: Sun, 28 May 2000 16:45:24 +0100 (GMT Daylight Time)
Cc: s-news@wubios.wustl.edu
In-reply-to: <NDBBLBEPLKICCDJJJHDECECJCDAA.allanr@gurunet.com>
Sender: owner-s-news@wubios.wustl.edu
On Sun, 28 May 2000, Allan Reiffman wrote:

> 
> 
> Sorry to bother with what is probably an easy task, but I've been knocking
> my head against the wall on this one!
> 
> I'm trying to create a simple line-plot of a vector of data, where each row
> is associated with a calendar date. What I would like is for the x-axis tick
> labels to show the day-of-the week values e.g., Sunday, Monday. Tuesday,
> etc...
> 
> I can get the weekday values ok, using the weekday() function, but these
> values will not work as input to either plot() or xyplot() - looks like the
> function expects numeric values.
> 
> Using ts.plot() almost works (after creating a cts object) but the labels
> are the dates themselves, not the days of the week. I thought about
> modifying the ts.plot() function but it looked kinda hairy...
> 
> The closest I've come is by doing a plot.factor() with a character="x"
> option. This gives a plot of the data points and I guess I could overlay a
> line plot on top of this, but I keep thinking that there MUST be an easier
> way!


Yes. Use plot(xaxs="n") and then axis. interaction.plot and boxplot
(as I recall) have examples of doing this.

-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

-----------------------------------------------------------------------
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>