Re: [R] Scatter plot - using colour to group points?

2011-11-23 Thread Ian Robertson
Hello all, Yesterday I wrote Michael Weylandt to ask for some help in understanding a line of code he used responding to SarahH's query about controlling colours in scatter plots. He wrote an excellent explanation that deserves to be shared here. Below I include the code I wrote while experim

Re: [R] Scatter plot - using colour to group points?

2011-11-22 Thread SarahH
Success with the lines command and col argument! I have some nice point and line plots. Thanks so much for you help. Ongoing project - I will probably be back! Sarah -- View this message in context: http://r.789695.n4.nabble.com/Scatter-plot-using-colour-to-group-points-tp4092794p4097625.html S

Re: [R] Scatter plot - using colour to group points?

2011-11-22 Thread R. Michael Weylandt
There's also the lines() command which takes a col argument if you want to do multiple lines (I usually wind up wrapping it in a for loop though there might be something smarter) ggplot2 is great, though the learning curve is a little rough: you can get good help here but if you go down that pa

Re: [R] Scatter plot - using colour to group points?

2011-11-22 Thread SarahH
Thanks all for suggestions. I now have a nice plot showing the temperature of 6 different sites, each site distinguished by different coloured points, using nested ifelse. My apologies I thought I could change the type to "l" and the same arguments would be applied to line graph, with 6 different

Re: [R] Scatter plot - using colour to group points?

2011-11-21 Thread Jim Lemon
On 11/22/2011 05:00 PM, David Winsemius wrote: On Nov 21, 2011, at 10:18 PM, R. Michael Weylandt wrote: I don't think you can do different colors for a single line (not an ifelse thing, just a what would that mean sort of thing), but a plot type like "b" "o" or "h" will work the same way. I

Re: [R] Scatter plot - using colour to group points?

2011-11-21 Thread David Winsemius
On Nov 21, 2011, at 10:18 PM, R. Michael Weylandt wrote: I don't think you can do different colors for a single line (not an ifelse thing, just a what would that mean sort of thing), but a plot type like "b" "o" or "h" will work the same way. I think Jim Lemon has a multicolored line function

Re: [R] Scatter plot - using colour to group points?

2011-11-21 Thread R. Michael Weylandt
I don't think you can do different colors for a single line (not an ifelse thing, just a what would that mean sort of thing), but a plot type like "b" "o" or "h" will work the same way. Michael On Mon, Nov 21, 2011 at 4:23 PM, SarahH wrote: > I got the colour vector with ifelse to work, great! T

Re: [R] Scatter plot - using colour to group points?

2011-11-21 Thread John Kane
Another approach would be to use ggplot2.  Code can look a bit daunting to begin with but ggplot2 is a very versitile graphing package and well worth learning. Simple example = library(ggplot2) mydata <- data.frame(site=c("A","A","A", "

Re: [R] Scatter plot - using colour to group points?

2011-11-21 Thread SarahH
I got the colour vector with ifelse to work, great! Thank you. Is it possible to use the ifelse colour vector with other plot types? For example with type=l ? I tried but the graphic came back with blue lines for both sites and also a straight line connecting the start and end point of the data?

Re: [R] Scatter plot - using colour to group points?

2011-11-21 Thread R. Michael Weylandt
I think the easiest way to do this is to set up a color vector with ifelse and hand that off to the plot command: something like col = ifelse(TEMP3[,"SITE"] == "BG1", "blue", "green") # Syntax is ifelse(TEST, OUT_IF_TRUE, OUT_IF_FALSE) For more complicated schemes, a set of nested ifelse()'s can

Re: [R] Scatter plot - using colour to group points?

2011-11-21 Thread David Winsemius
On Nov 21, 2011, at 2:17 PM, SarahH wrote: Dear All, I am very new to R - trying to teach myself it for some MSc coursework. I am plotting temperature data for two different sites over the same time period which I have downloaded from a university weather station data archive. I am usi