[R] formatting dates in axis labels (ggplot2)

hadley wickham h.wickham at gmail.com
Fri Nov 20 21:36:06 CET 2009


Hi Michael,

> I'm having trouble figuring out how to format Date variables when used as
> axis labels in graphs.
> The particular case here is an attempt to re-create Nightingale's coxcomb
> graph with ggplot2,
> where I'd like the months to be labeled as "Mar 1885", "Apr 1885", using a
> date format
> of "%b %Y" applied to label the dates, or really anything other than
> "1885-03-01". I know the solution has to do with formatting the dates, while
> preserving their
> status as an ordered factor, but I don't know how to do that.

Dates are, by their very nature, ordered so you don't need to keep
them as an ordered factor.  If you don't do that you'll find that the
scale_date formatting options will work.

Hadley


-- 
http://had.co.nz/




More information about the R-help mailing list