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

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-22 Thread R. Michael Weylandt michael.weyla...@gmail.com
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

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

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

2011-11-21 Thread SarahH
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 using the following code to create the plot plot (

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

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

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 John Kane
: [R] Scatter plot - using colour to group points? To: r-help@r-project.org Received: Monday, November 21, 2011, 2:17 PM 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

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 sarah@hotmail.co.uk wrote: I got the colour vector with ifelse

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 in

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 think