Greg Blevins
2004-Dec-21 00:03 UTC
[R] How to display each symbol in a different color using plot with summary.formula.reverse
Dear R Masters, I have searched high and low (the help archives and my various R reference material and help files) for a solution to what appears to me to be quite a simple problem. In the following syntax, variable n10 has three levels. I would like the symbols that appear in the graph for these three levels to be different colors. The best I have been able to do is to have the Key display three colors, but the symbols in the graph only show up in black and white. Any suggestions? par(cex=.8) s <- summary(n10 ~ n13, method="reverse", test=T) plot(s, dotsize=1.2, cex.labels=.7, cex.axis=.5, cex.main=.5, which="categorical") Key(locator(1)) R version 2.0.1 Windows XP Thank you, Greg Blevins The Market Solutions Group [[alternative HTML version deleted]]
F Z
2004-Dec-21 02:54 UTC
[R] How to display each symbol in a different color using plot withsummary.formula.reverse
Hi Greg Try the argument "col" within plot. Using your example you could try: s <- summary(n10 ~ n13, method="reverse", test=T) col <- c("black", "maroon", red") plot(s, dotsize=1.2, col =col[YourData[,n10]] ,cex.labels=.7, cex.axis=.5, cex.main=.5, which="categorical") I hope that this helps Francisco PS: In the future try to show your data structure and levels in the example, it makes it easier for us to understand what you want to do.>From: "Greg Blevins" <gblevins at mn.rr.com> >To: "R-Help" <r-help at stat.math.ethz.ch> >Subject: [R] How to display each symbol in a different color using plot >withsummary.formula.reverse >Date: Mon, 20 Dec 2004 18:03:30 -0600 > >Dear R Masters, > >I have searched high and low (the help archives and my various R reference >material and help files) for a solution to what appears to me to be quite a >simple problem. In the following syntax, variable n10 has three levels. I >would like the symbols that appear in the graph for these three levels to >be different colors. The best I have been able to do is to have the Key >display three colors, but the symbols in the graph only show up in black >and white. Any suggestions? > >par(cex=.8) >s <- summary(n10 ~ n13, method="reverse", test=T) >plot(s, dotsize=1.2, cex.labels=.7, cex.axis=.5, cex.main=.5, >which="categorical") >Key(locator(1)) > >R version 2.0.1 >Windows XP > >Thank you, > >Greg Blevins >The Market Solutions Group > [[alternative HTML version deleted]] > >______________________________________________ >R-help at stat.math.ethz.ch mailing list >https://stat.ethz.ch/mailman/listinfo/r-help >PLEASE do read the posting guide! >http://www.R-project.org/posting-guide.html
Frank E Harrell Jr
2004-Dec-21 13:25 UTC
[R] How to display each symbol in a different color using plot with summary.formula.reverse
Greg Blevins wrote:> Dear R Masters, > > I have searched high and low (the help archives and my various R reference material and help files) for a solution to what appears to me to be quite a simple problem. In the following syntax, variable n10 has three levels. I would like the symbols that appear in the graph for these three levels to be different colors. The best I have been able to do is to have the Key display three colors, but the symbols in the graph only show up in black and white. Any suggestions? > > par(cex=.8) > s <- summary(n10 ~ n13, method="reverse", test=T) > plot(s, dotsize=1.2, cex.labels=.7, cex.axis=.5, cex.main=.5, which="categorical") > Key(locator(1)) > > R version 2.0.1 > Windows XP > > Thank you, > > Greg Blevins > The Market Solutions GroupGreg, These kinds of questions are probably best directed at package maintainers. This would be an enhancement to the dotchart2 function used by plot.summary.formula.reverse, and the addition of a new argument to it from plot.... I have found symbols (esp. circle vs. triangle) to be more effective for this purpose so I am not motivated to work on this very soon but would consider it. -Frank -- Frank E Harrell Jr Professor and Chair School of Medicine Department of Biostatistics Vanderbilt University