Re: [R] Control of x-axis variable ordering in ggplot

2015-10-23 Thread Hadley Wickham
You have two problems: * geom_line() always draws from right-to-left * you're defining colour outside of the plot in a very non-ggplot2 way. Here's how I'd do it: library(ggplot2) data <- data.frame( x = rep(1:4, each = 25), y = rep(1:25, times = 4), g = rep(1:4, each = 25) ) data$x <-

Re: [R] Control of x-axis variable ordering in ggplot

2015-10-23 Thread sbihorel
Hi, I want to thank Jeff, Dennis, c06n, and Hadley for their replies and explanations. As you probably guessed, I am fairly new to ggplot am trying to loose my lattice reflex while transitioning to ggplot. Thank for the link to the ggplot external documentation. Sebastien On 10/23/2015

Re: [R] Control of x-axis variable ordering in ggplot

2015-10-23 Thread c06n
Hi, are you trying to do the same thing with ggplot as with lattice? In this case, your solution looks probably like this: ggplot(data, aes(x, y, group = g)) + geom_path(aes(colour = g)) If you haven’t done so yet, I strongly recommend reading through the ggplot2 documentation:

Re: [R] Control of x-axis variable ordering in ggplot

2015-10-22 Thread Jeff Newmiller
The ggplot function has no display behaviour. You have to couple it with a geom function to define how the data will be displayed. Read ?geom_line and ?geom_poly. --- Jeff NewmillerThe .

[R] Control of x-axis variable ordering in ggplot

2015-10-22 Thread sbihorel
Hi, Given a certain data.frame, the lattice xyplot function will plot the data as.is and join the data point in the order of the data frame. It is my (probably flawed) understanding that, using the same data frame, ggplot orders the data by increasing order of the x-axis variable. Can one