Jason Rupert
2009-Aug-12 21:29 UTC
[R] Another Plotting Hint - changing fill color for points
Is it possible to change the fill color of a point? For example, the outer color being "Blue" and inner color being "Grey". I've tried changing "col" and "bg", but that does not seem to have the desired effect. Below is another attempt, but the pixel resolution of the points function does not appear to be high enough for this to work: figure_file_name_and_path<-paste("Test.wmf", sep="") vals_200<-rnorm(200) vals_201<-rnorm(200) win.metafile(file=as.character(figure_file_name_and_path), pointsize = 10) plot(-4:4, -4:4, type = "n")# setting up coord. system points(vals_201, vals_200, col = "blue", bg = "white", pch=19, cex =1.7) points(vals_201, vals_200, col = "grey", bg = "white", pch=19, cex =1.5) points(rnorm(100)/2, rnorm(100)/2, col = "blue", bg = "white", pch=19, cex =1.5) dev.off() As a second question, is there any way to increase the pixel resolution of the points produced on the plot so that they are perfect circles. I just noticed that the fill does not perfectly fill the points on the plot and there are some pixels outside the circle. Thanks again.
Sarah Goslee
2009-Aug-12 21:56 UTC
[R] Another Plotting Hint - changing fill color for points
Yes, you can do that. You need to specify pch in the range of 21-25, and can then specify both col and bg (background color). Oddly, the help for this option is under ?points rather than ?par or ?pch, but there are many examples. Your second question would depend heavily on the device you use and its associated settings, but using the above solution should solve your problem. Sarah On Wed, Aug 12, 2009 at 5:29 PM, Jason Rupert<jasonkrupert at yahoo.com> wrote:> > Is it possible to change the fill color of a point? ?For example, the outer color being "Blue" and inner color being "Grey". > I've tried changing "col" and "bg", but that does not seem to have the desired effect. > > Below is another attempt, but the pixel resolution of the points function does not appear to be high enough for this to work: > > figure_file_name_and_path<-paste("Test.wmf", sep="") > > vals_200<-rnorm(200) > vals_201<-rnorm(200) > > win.metafile(file=as.character(figure_file_name_and_path), pointsize = 10) > plot(-4:4, -4:4, type = "n")# setting up coord. system > points(vals_201, vals_200, col = "blue", bg = "white", pch=19, cex =1.7) > points(vals_201, vals_200, col = "grey", bg = "white", pch=19, cex =1.5) > points(rnorm(100)/2, rnorm(100)/2, col = "blue", bg = "white", ?pch=19, cex =1.5) > dev.off() > > As a second question, is there any way to increase the pixel resolution of the points produced on the plot so that they are perfect circles. ?I just noticed that the fill does not perfectly fill the points on the plot and there are some pixels outside the circle. > > Thanks again. >-- Sarah Goslee http://www.functionaldiversity.org