# [R] How to draw Bubble chart with mini pie charts as bubbles in R

Agony agony_jah at yahoo.com
Sun Jun 15 15:25:01 CEST 2014

```Hi Jim,
Very great help.
Bunch of thanks.

Yours,
Amir
--------------------------------------------
On Sun, 6/15/14, Jim Lemon <jim at bitwrit.com.au> wrote:

Subject: Re: [R] How to draw Bubble chart with mini pie charts as bubbles in R
To: r-help at r-project.org

Date: Sunday, June 15, 2014, 5:10 AM

On Sat, 14 Jun 2014
01:03:21 PM Agony wrote:
> Dear all,
> Good day!
>
> Could anybody help me how to draw a bubble
chart with mini pie
charts as
> bubbles in R ? Introducing any
experiences, books, booklet or source
code
> will
appreciated.
>
Hi
Amir,
The floating.pie function (plotrix)
might do what you want. For
example:

# first create a simple
function to do the chart

sector_col=NULL,main="",xlab="",ylab="")
{

nbubbles<-length(xpos)

if(is.null(sector_col)) {

sector_col<-list()
for(scol in
1:nbubbles)
sector_col[[scol]]<-rainbow(length(sectors[[scol]]))
}

plot(0,xlim=xlim,ylim=ylim,type="n",
main=main,xlab=xlab,ylab=ylab)
for(bubble in 1:nbubbles)

floating.pie(xpos=xpos[bubble],ypos=ypos[bubble],
col=sector_col[[bubble]])
}
# set the x positions
xpos<-c(2,4,6,8,10)
# and
the y positions
ypos<-c(4,8,6,10,2)
# these are the sector extents of the pies
sectors<-list(1:4,c(5,3,8,6,2),c(3,2,1),c(3,7,5,8),c(2.5,3.7))
# get the plotrix package
library(plotrix)