Re: [R] R GUI plot by color
Ok, I will take it into account in the future. Thanks!! -- View this message in context: http://r.789695.n4.nabble.com/R-GUI-plot-by-color-tp4710297p4710382.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R GUI plot by color
On 7/24/2015 6:23 AM, Jim Lemon wrote: Hi jpara3, Your example, when I got it to go: one-c(3,2,2) two-c(a,b,b) data-dataframe(one,two) plot(data$one,col=data$two) Wow Jim. Psychic indeed! Not only did you answer with NO reproducible example, but on round 2 you fixed a non-working example and explained why it was an accident that it works. What is the stock market about to do? :) jpara3 - Those of us without Jim's talent can be more helpful if you read and follow the guide at the bottom of each email.: PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. does indeed work, and I'll explain how. You are plotting the values of data$one against the _values_ of data$two (see point 3 of my response). In this case, the values of data$two are of class factor, which means that they have numeric values attached to the levels (a, b) of the factor. When you pass these values as the col argument, they are silently converted to their numeric values (1,2,2). In the default palette, these numbers represent the colors - black, red, red. Those are the colors in which the points are plotted. So far, so good. Let's look at the other two points that I guessed. 1) The column names of data2 are not numbers colnames(data) [1] one two As you can see, the column names are character variables, and they don't translate to numbers: as.numeric(colnames(data)) [1] NA NA 2) The number of columns in data2 is not equal to the number of values in data1 that you are plotting It's pretty obvious that there are two values in the column names and three in the vector of values that you are plotting in your example.So, I think I got three out of three without knowing what the data were. Jim On Fri, Jul 24, 2015 at 7:53 PM, jpara3 j.para.fernan...@hotmail.com wrote: I have done a trial with a dataframe like this: one-c(3,2,2) two-c(a,b,b) data-dataframe(uno,dos) plot(data$one,col=data$two) and it plots perfect. If you paste the code above in R, it has errors and does NOT plot perfectly. I still did not understand what you were trying to do. You owe Jim big time. If I try it with the code that i have post in the first message, selecting data1 and data2 as i nthis example, the plot is plotted, but all dots with the same color. Thanks for the answer but noone of the 3 topics is the root problem. -- View this message in context: http://r.789695.n4.nabble.com/R-GUI-plot-by-color-tp4710297p4710300.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] R GUI plot by color
Hi, I want to do a plot from a variable (which i select from a listbox) with the color factor of the variable that i have selected from another listbox. To be not very heavy pasting all the code, i will only paste real important parts: data1 and data2 are the extacted parts of the dataframes data from a tcltk listbox: data1- dataframe[as.numeric(tkcurselection(tl))+1] data2- dataframe[as.numeric(tkcurselection(tl))+1] As i want to plot the data1 with the color of data2, i use this code: plot(data1,col=colnames(data2)) This works perfect for plotting the data1 variable, but it do not change the col of the dots by data2. I also have probed with plot(data1,col=factor(colnames(data2))) But nothing happens with the color. Thanks!! -- View this message in context: http://r.789695.n4.nabble.com/R-GUI-plot-by-color-tp4710297.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R GUI plot by color
Hi jpara3, Hmmm. It's becoming clearer, yes I think the answer is emerging from the swirling clouds of uncertainty. 1) The column names of data2 are not numbers 2) The number of columns in data2 is not equal to the number of values in data1 that you are plotting 3) You probably want to plot colors determined by the values in data2, not the names of its columns Please send payment for this psychic reading to Jim On Fri, Jul 24, 2015 at 6:43 PM, jpara3 j.para.fernan...@hotmail.com wrote: Hi, I want to do a plot from a variable (which i select from a listbox) with the color factor of the variable that i have selected from another listbox. To be not very heavy pasting all the code, i will only paste real important parts: data1 and data2 are the extacted parts of the dataframes data from a tcltk listbox: data1- dataframe[as.numeric(tkcurselection(tl))+1] data2- dataframe[as.numeric(tkcurselection(tl))+1] As i want to plot the data1 with the color of data2, i use this code: plot(data1,col=colnames(data2)) This works perfect for plotting the data1 variable, but it do not change the col of the dots by data2. I also have probed with plot(data1,col=factor(colnames(data2))) But nothing happens with the color. Thanks!! -- View this message in context: http://r.789695.n4.nabble.com/R-GUI-plot-by-color-tp4710297.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R GUI plot by color
I have done a trial with a dataframe like this: one-c(3,2,2) two-c(a,b,b) data-dataframe(uno,dos) plot(data$one,col=data$two) and it plots perfect. If I try it with the code that i have post in the first message, selecting data1 and data2 as i nthis example, the plot is plotted, but all dots with the same color. Thanks for the answer but noone of the 3 topics is the root problem. -- View this message in context: http://r.789695.n4.nabble.com/R-GUI-plot-by-color-tp4710297p4710300.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R GUI plot by color
Hi jpara3, Your example, when I got it to go: one-c(3,2,2) two-c(a,b,b) data-dataframe(one,two) plot(data$one,col=data$two) does indeed work, and I'll explain how. You are plotting the values of data$one against the _values_ of data$two (see point 3 of my response). In this case, the values of data$two are of class factor, which means that they have numeric values attached to the levels (a, b) of the factor. When you pass these values as the col argument, they are silently converted to their numeric values (1,2,2). In the default palette, these numbers represent the colors - black, red, red. Those are the colors in which the points are plotted. So far, so good. Let's look at the other two points that I guessed. 1) The column names of data2 are not numbers colnames(data) [1] one two As you can see, the column names are character variables, and they don't translate to numbers: as.numeric(colnames(data)) [1] NA NA 2) The number of columns in data2 is not equal to the number of values in data1 that you are plotting It's pretty obvious that there are two values in the column names and three in the vector of values that you are plotting in your example.So, I think I got three out of three without knowing what the data were. Jim On Fri, Jul 24, 2015 at 7:53 PM, jpara3 j.para.fernan...@hotmail.com wrote: I have done a trial with a dataframe like this: one-c(3,2,2) two-c(a,b,b) data-dataframe(uno,dos) plot(data$one,col=data$two) and it plots perfect. If I try it with the code that i have post in the first message, selecting data1 and data2 as i nthis example, the plot is plotted, but all dots with the same color. Thanks for the answer but noone of the 3 topics is the root problem. -- View this message in context: http://r.789695.n4.nabble.com/R-GUI-plot-by-color-tp4710297p4710300.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R GUI plot by color
Yes, you were right!! Thanks. -- View this message in context: http://r.789695.n4.nabble.com/R-GUI-plot-by-color-tp4710297p4710320.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.