Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here is a solution (inspired by @Edward's solution for <a href="https://stackoverflow.com/questions/11777124/three-way-color-gradient-fill-in-r?lq=1">this question</a>):</p> <pre><code>#First your data: y&lt;-c(123,92,104,23,17,89,13) x&lt;-c(11,45,24,50,18,7,2) size&lt;-c(1236,1067,1176,610,539,864,1026) radius&lt;-sqrt(size/pi) col&lt;-c(2,2,3,4,5,5,6) name&lt;-c("Acura", "Alfa Romeo","AM General","Aston Martin Lagonda","Audi","BMW","Bugatti") #Then a simple function to draw a circle based on its center and its radius: circle &lt;- function (r, x0, y0, col){ t &lt;- seq(0, 2 * pi, by = 0.01) x &lt;- r * cos(t) + x0 y &lt;- r * sin(t) + y0 lines(x, y, col=col) } #This is a smoothing factor: sm &lt;- 500 #The asp parameter is important here since we are actually drawing the circles and not plotting some circle symbols: if asp is not equal to 1 they will appear as ellipse. plot(x,y,type="n",asp=1) #This can probably be vectorized but I'm not a good vectorizer so if anyone wants to give it a try: for(j in 1:length(x)){ radius[j]*sm:1/sm -&gt; radiuses colorRampPalette(c(palette()[col[j]], "white"))-&gt;col_grad col_grad(length(radiuses))-&gt;colx for(i in 1:length(radiuses)){circle(radiuses[i], x[j], y[j], col=colx[i])} } text(x, y, name, cex=1.5,font=4) </code></pre> <p>See <code>?colorRampPalette</code> for more information on how this function works.</p> <p><img src="https://i.stack.imgur.com/FUy3y.png" alt="enter image description here"></p> <p><strong>Edit: with shadows</strong></p> <pre><code> offset&lt;-c(2,-2) #Offset of the shadow circles library(scales) #For function alpha plot(x,y,type="n",asp=1) for(j in 1:length(x)){ radius[j]*sm:1/sm -&gt; radiuses colorRampPalette(c(palette()[col[j]], "white"))-&gt;col_grad col_grad(length(radiuses))-&gt;colx for(i in 1:length(radiuses)){circle(radiuses[i], x[j]+offset[1], y[j]+offset[2], col=alpha("grey90",0.1))} #the alpha, the nuance of grey can be tweaked with obviously for the desired effect for(i in 1:length(radiuses)){circle(radiuses[i], x[j], y[j], col=colx[i])} } text(x, y, name, cex=1.5,font=4) </code></pre> <p><img src="https://i.stack.imgur.com/deFut.png" alt="enter image description here"></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload