rileycattus
rileycattus

Reputation: 31

How to normalize circle sizes in R

I have a data set as follows and am creating a bubbleplot using symbols, with the Z column used as bubble size:

 X       Y      Z       TITLE
151.2  31.5    51023     xyz
160.2  51.8    4912      xyz
191.7  2.1     874201    abc

radius <- sqrt(data$z/pi)
symbols(data$x,data$y,circles=radius,inches=0.35,
cex.axis=1.5,cex.lab=1.5,xlab="xlab", ylab="ylab")

I then would like to have a second bubbleplot with any Title of "abc" removed. However, when I do this, the bubbles then resize themselves in comparison to the original plot. How can I normalize bubble size between plots?

Upvotes: 0

Views: 170

Answers (1)

d.b
d.b

Reputation: 32548

Try something like

data$radius <- sqrt(data$Z/pi)/50
with(data[data$TITLE != "abc",],
     symbols(x = X, y = Y, circles = radius,
             inches = FALSE, asp = 1,
             xlim = c(140, 240), ylim = c(-10, 60)))

and

with(data,
     symbols(x = X, y = Y, circles = radius,
             inches = FALSE, asp = 1,
             xlim = c(140, 240), ylim = c(-10, 60)))

If you specify inches = 0.35, the circles are scaled to make largest circle dimension 0.35 inches. Read more at ?symbols

Upvotes: 1

Related Questions