[R] Changing X axis of ggplot

Hasan Diwan hasan.diwan at gmail.com
Tue Jan 3 06:55:26 CET 2012


Aren,
On 2 January 2012 19:34, Aren Cambre <aren at arencambre.com> wrote:
> I am making a plot using this:
> p <- ggplot(dallas, aes(x = offense_hour)) + geom_bar() + coord_polar()
> The plot shows up fine, but the X axis labels are 0.0 through 1.0. How
> do I convert this to 0:00 through 23:59 (or whatever may be
> appropriate given the breaks)?

Seeing as there is no source code, I'm taking a stab in the dark, but
the below gives me a pie chart:
to <- as.POSIXlt('23:59:59', format='%H:%M:%S', origin=Sys.Date())
from <- as.POSIXlt('00:00:00', format='%H:%M:%S', origin=Sys.Date())
range <- seq(from, to, by = .5)
dallas <- data.frame(offense_hour = range, stuff = rnorm(c(1:length(range))))
p <- ggplot(dallas, aes(x = offense_hour) + geom_bar() + coord_polar)
-- 
Sent from my mobile device
Envoyait de mon portable



More information about the R-help mailing list