There are lots of different ways to do this. I don't use plotrix, which uses base R graphics functionality, so I can't help you with your current approach. However, it is easy to do this "by hand" in the newer, object-based grid package (on which ggpot and lattice are built) . The idea, which probably works for plotrix, too, is to simply draw concentric circles of *decreasing* radiii with a gradient of fill colors; each successive fill will overwrite the previous one.
Here's some code using grid that you can customize that gives you the idea. Obviously, you'd also have to add your color bar using grid graphics functionaity, which is again straightforward. grid.newpage() mycols<- colorRampPalette(c("yellow","orange","red")) radii = .3*seq(1,.05,length.out = 25) grid.circle(x=.5,y=.5, r = radii, gp= gpar(fill=mycols(25), lwd = 0)) However, probably plotrix and ggplot would allow you to do this more easily with higher level graphics funtions. Searching (e.g. on rseek.org) might bring up what you want if you don't get a more satisfactory reply here. Finally, **Please** post in plain text, not HTML. As you can see from the quoted message below, your text got mangled. This, of course, will discourage others to give you the response you need. Cheers, Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Tue, Oct 24, 2017 at 2:56 AM, Alaios via R-help <r-help@r-project.org> wrote: > Hi all,I would like to draw a simple circle where the color gradient > follows the rule color = 1/(r^2) where r is the distance from the circle. I > would also like to add a color bar with values going from -40 to -110 (and > associate those with the color gradient that fills the circle). > So far I experiemented with draw circle install.packages('plotrix') > require(plotrix)colors<-c('#fef0d9','#fdcc8a','#fc8d59','# > e34a33','#b30000')plot(c(-15,15),c(-15,15),type='n')draw.circle(0, 0, 10, > nv = 1000, border = NULL, col = colors[1], lty = 1, lwd = 1)draw.circle(0, > 0, 8, nv = 1000, border = NULL, col = colors[2], lty = 1, lwd = > 1)draw.circle(0, 0, 6, nv = 1000, border = NULL, col = colors[3], lty = 1, > lwd = 1)draw.circle(0, 0, 4, nv = 1000, border = NULL, col = colors[4], lty > = 1, lwd = 1)draw.circle(0, 0, 2, nv = 1000, border = NULL, col = > colors[5], lty = 1, lwd = 1) > > but this package does not give easily color gradients and so my solutions > contains 5 same colors filled rings. > Will there be any suggested improvements on my code above? > Thanks a lotAlex > [[alternative HTML version deleted]] > > ______________________________________________ > 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. > [[alternative HTML version deleted]] ______________________________________________ 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.