In R, I can plot circles at specified sizes using the symbols() function, but for some reason it won’t allow me to do it in color. For example, try this:

symbols (0, 0, circles=1, col="red")

It makes a black circle, just as if the “col” argument had never been specified. What’s wrong?

P.S. I could just write my own function to draw circles, but that would be cheating. . . .

Use fg="red" or bg="red" instead of col="red".

symbols (0, 0, circles=1, bg="red")

I don't know why buts it is fg instead of col to color symbols.

symbols(0, 0, circles = 1, fg = "red", bg = 'red')

Use "fg" (foreground) for the boundary of the symbol and, if you wish to fill it "bg" (background) for the fill colour. Don't ask me why.

symbols(0, 0, circles=1, fg="red")

symbols(0, 0, circles=1, bg="hotpink")

Read the help page. :-)

You could look at the 'balloonplot' function in Greg Warnes' gplot package for an example — it uses just the basic 'plot()' function with arguments for cex and col.

Try:

symbols (0, 0, circles=1, fg="red")

Thanks for the help, everyone!

Bob: You seem to be channeling a well-known denizen of the R-help list with your comment. But, let me tell you, I did read the help page! It had the following:

<pre>

… graphics parameters can also be passed to this function

</pre>

And so I foolishly assumed I could just pass along whatever graphics parameters I wanted. When "col" didn't work, I had no idea what to do.

Now that I've been told what to look for, I can see that "fg" and "bg" are parameters in the function, but I didn't notice them when I looked at the help function. One thing that certainly doesn't help is that the help page is full of unnecessary info: xlab, ylab, main, xlim, ylim are standard plotting options. I didn't notice the new stuff ("fg" and "bg") amid the clutter of the old.

I also tried googling "R symbols color" and various other combinations but with no luck.

Dirk: Yes, I must learn ggplot2. Perhaps that wouldn't be a bad New Year's resolution?

Hi Andrew, as all the others I found it as well.

I found it by just calling 'symbols' to look at the code. In this case it's nothing much impressive to look at. On the second line you see the author reassigning the par("col").

plot(0,0,cex=5.0,col=2)

This is probably the wrong place to ask, but it should be a snap for you guys.

How do you add x-lim and y-lim to a hexbin scatterplot? It doesn't allow me to do that, or any par() functions either.

Don't google for R topics… RSeek it!

http://www.rseek.org/

<a href="http://www.rseek.org/?cx=010923144343702598753%3Aboaz1reyxd4&q=R+symbols+color&sa=Search&cof=FORID%3A11&siteurl =www.rseek.org%252F#962" rel="nofollow"> <a href="http://;http://www.rseek.org/?cx=010923144343702598753%3Aboaz1reyxd4&q=R+symbols+color&sa=Search&cof=FORID%3A11&siteurl <a href="http://=www.rseek.org%252F#962“” target=”_blank”>=www.rseek.org%252F#962“ target=”_blank”>;http://www.rseek.org/?cx=010923144343702598753%3Aboaz1reyxd4&q=R+symbols+color&sa=Search&cof=FORID%3A11&siteurl <a href="http://=www.rseek.org%252F#962” target=”_blank”>=www.rseek.org%252F#962