Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to use R to build bubble charts with gradient fills
    primarykey
    data
    text
    <p>I use R code below to build bubble chart.</p> <pre><code>pdf(file='myfigure.pdf',height=10,width=13) 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") symbols(x,y, circles=radius,fg="white",bg=col,ylim=c(-20,140)) text(x, y, name, cex=1.5,font=4) dev.off() </code></pre> <p><img src="https://i.stack.imgur.com/x9OLf.png" alt="enter image description here"> But I want the bubbles with 3d surface, say gradient fills and shadow. like the chart below. <img src="https://i.stack.imgur.com/Gs9YB.png" alt="enter image description here"></p> <p>Anyone knows how to use R to release it? Thanks!</p> <p>Thanks for all the suggestions.While finally I tried a silly way by drawing multiple circles from dark to light to make it gradient filled. Any suggestions to make it better? Thanks! <img src="https://i.stack.imgur.com/qRPjK.png" alt="enter image description here"></p> <pre><code>makeTransparent&lt;-function(someColor, alpha) { newColor&lt;-col2rgb(someColor) apply(newColor, 2, function(curcoldata){rgb(red=curcoldata[1], green=curcoldata[2], blue=curcoldata[3],alpha=alpha,maxColorValue=255)}) } pdf(file='myfigure.pdf',height=10,width=13) 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") x2&lt;-c() y2&lt;-c() circles&lt;-c() bg&lt;-c() fg&lt;-c() num&lt;-30 radius_min&lt;-0.3 alpha_min&lt;-40 alpha_max&lt;-180 for (i in 1:num){ x2&lt;-c(x2,x) y2&lt;-c(y2,y) circles&lt;-c(circles,radius*(radius_min+(i-1)*(1-radius_min)/num)) bg&lt;-c(bg,makeTransparent(col,alpha=alpha_max-(i-1)*(alpha_max-alpha_min)/num)) if(i!=num){fg&lt;-c(fg,makeTransparent(col,alpha=alpha_max-(i-1)*(alpha_max-alpha_min)/num))}else{fg&lt;-c(fg,rep('white',length(x)))} } symbols(x2,y2,circles=circles,fg=fg,bg=bg) text(x, y, name, cex=1.5,font=4) dev.off() </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    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