Hi, I am currently building graphs using dochart(). I plotted the points in two different colors according to specific criteria from my dataset. Later, I decided to also give them different symbols, for easier reading if printed. I got quite a surprise when I realized that, even though I gave the same variable to both color= and pch= , I got a mix of the colors and symbols. I wanted one type of symbol to be only one color, and the second only the other color, and it is clearly not what happened. From my data, I would say that the pch= argument is not dealing properly with the variable I gave it. I tried using a dataset from R to see if this was only in my dataset, and it did the same. here?s a reproducible example, using beaver1: dotchart(beaver1$temp, groups=factor(beaver1$day), color=as.factor(beaver1$activ), pch=beaver1$activ) Does anyone know why, with the same variable, the arguments color & pch give different results? That would be of great help, since now I am no longer sure which one isthe correct representation of my data. Best regards & many thanks for the help Simon Gingins
Look at your code! color was specified as "as.factor..." and pch was specifed as "..." (no as.factor() ) Read an R tutorial on how factors are coded for why this would make a difference. -- Bert Bert Gunter "Data is not information. Information is not knowledge. And knowledge is certainly not wisdom." -- Clifford Stoll On Tue, Nov 3, 2015 at 5:58 AM, GINGINS Simon <simon.gingins at unine.ch> wrote:> Hi, > > I am currently building graphs using dochart(). I plotted the points in two different colors according to specific criteria from my dataset. Later, I decided to also give them different symbols, for easier reading if printed. I got quite a surprise when I realized that, even though I gave the same variable to both color= and pch= , I got a mix of the colors and symbols. I wanted one type of symbol to be only one color, and the second only the other color, and it is clearly not what happened. From my data, I would say that the pch= argument is not dealing properly with the variable I gave it. I tried using a dataset from R to see if this was only in my dataset, and it did the same. here?s a reproducible example, using beaver1: > > dotchart(beaver1$temp, groups=factor(beaver1$day), color=as.factor(beaver1$activ), pch=beaver1$activ) > > Does anyone know why, with the same variable, the arguments color & pch give different results? > > That would be of great help, since now I am no longer sure which one isthe correct representation of my data. > > Best regards & many thanks for the help > > Simon Gingins > ______________________________________________ > R-help at 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.
On 03/11/2015 8:58 AM, GINGINS Simon wrote:> Hi, > > I am currently building graphs using dochart(). I plotted the points in two different colors according to specific criteria from my dataset. Later, I decided to also give them different symbols, for easier reading if printed. I got quite a surprise when I realized that, even though I gave the same variable to both color= and pch= , I got a mix of the colors and symbols. I wanted one type of symbol to be only one color, and the second only the other color, and it is clearly not what happened. From my data, I would say that the pch= argument is not dealing properly with the variable I gave it. I tried using a dataset from R to see if this was only in my dataset, and it did the same. here?s a reproducible example, using beaver1: > > dotchart(beaver1$temp, groups=factor(beaver1$day), color=as.factor(beaver1$activ), pch=beaver1$activ) > > Does anyone know why, with the same variable, the arguments color & pch give different results? > > That would be of great help, since now I am no longer sure which one isthe correct representation of my data. > > Best regards & many thanks for the helpLooks like a bug in dotchart. When you specify groups, it sorts the data to put it into groups. It also sorts the colors, but it doesn't sort the pch values, so they end up associated with the wrong points. A workaround would be for you to do the sorting in advance. For example, groups <- factor(beaver1$day) o <- sort.list(as.numeric(groups), decreasing = TRUE) tmp <- beaver1[o,] dotchart(tmp$temp, groups=factor(tmp$day), color=as.factor(tmp$activ), pch=tmp$activ) Duncan Murdoch
... and see also the "color specification" info in ?par as well as the linked ?palette. You may be wrapping around if yu have more categories than colors in your palette. -- Bert Bert Gunter "Data is not information. Information is not knowledge. And knowledge is certainly not wisdom." -- Clifford Stoll On Tue, Nov 3, 2015 at 7:42 AM, Bert Gunter <bgunter.4567 at gmail.com> wrote:> Look at your code! > > color was specified as "as.factor..." > and pch was specifed as "..." (no as.factor() ) > > Read an R tutorial on how factors are coded for why this would make a > difference. > > -- Bert > > > Bert Gunter > > "Data is not information. Information is not knowledge. And knowledge > is certainly not wisdom." > -- Clifford Stoll > > > On Tue, Nov 3, 2015 at 5:58 AM, GINGINS Simon <simon.gingins at unine.ch> wrote: >> Hi, >> >> I am currently building graphs using dochart(). I plotted the points in two different colors according to specific criteria from my dataset. Later, I decided to also give them different symbols, for easier reading if printed. I got quite a surprise when I realized that, even though I gave the same variable to both color= and pch= , I got a mix of the colors and symbols. I wanted one type of symbol to be only one color, and the second only the other color, and it is clearly not what happened. From my data, I would say that the pch= argument is not dealing properly with the variable I gave it. I tried using a dataset from R to see if this was only in my dataset, and it did the same. here?s a reproducible example, using beaver1: >> >> dotchart(beaver1$temp, groups=factor(beaver1$day), color=as.factor(beaver1$activ), pch=beaver1$activ) >> >> Does anyone know why, with the same variable, the arguments color & pch give different results? >> >> That would be of great help, since now I am no longer sure which one isthe correct representation of my data. >> >> Best regards & many thanks for the help >> >> Simon Gingins >> ______________________________________________ >> R-help at 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.