[R] draw a circle with a gradient fill

Alaios alaios at yahoo.com
Tue Oct 24 11:56:44 CEST 2017


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]]



More information about the R-help mailing list