This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Bubble plot in R

I am trying to create a bubble plot in R but I am getting blurry outline. I need the bubbles to be solid filled and distinct boundary. my code is:

library(ggplot2)
# creating data set columns
x <- c (0,0,0,0)
y <- c(6,5,4,1)
r <- c(1586,106,452,2017)

color <- c(1,2,3,6)

cbp1 <- c("violet",  "violetred3", "violetred3", "magenta3")
sizeRange <- c(10,30)

# creating the dataframe from the above 
# columns
data <- data.frame(x, y, r, color)



ggplot(data, aes(x = x, y = y,size = r,fill = r, color=as.factor(color))) +
            ylim(-0.5,6.5) +
                #geom_point(alpha = 0.7) + scale_color_brewer(palette="Dark2") +
                 geom_point(alpha = 0.7) + scale_color_manual(values = cbp1) +
                 scale_size(range = sizeRange, name="index") +

                 theme_minimal() +
  theme(
    legend.position = "none",
    axis.text = element_blank(),
    axis.title = element_blank(),
    panel.grid = element_blank(),
    ) 
ggplot

Problem is not clear. Please post the image.

ggplot(data, aes(x = x, y = y,size = color , fill=r)) +
    geom_point(alpha = 0.7, shape = 21,colour = "black", stroke=2) +
    scale_size(range = sizeRange) +
    ylim(c(min(y)-0.5,max(y)+0.5)) +
    theme(legend.position = "none") 

enter image description here

0 answers

No answers yet.

Log in to answer this question.