0

I want to create a bubble plot without the y axis, meaning the x axis represents a range between certain values and the size of the bubbles corresponds to a "number" variable.

Since geom_point() requires a y variable, I created a new column with only zero values and assigned it to the y axis.

ggplot(df, aes(x=range, y=new, size = numberPoints)) +
    geom_point(alpha=0.5, shape=19) +
    scale_size(range = c(.1, 24)) +
    scale_y_continuous(breaks = NULL)

However, it gave the following result (the y axis is too large):

enter image description here

I only wanted the bubbles above the x axis (without too much space), but I can't find a way to do it.

Vinícius Félix
  • 8,448
  • 6
  • 16
  • 32
Dahlia
  • 7
  • 2
  • Can you make your post [reproducible](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) and provide `dput(df)`? – jrcalabrese Dec 03 '22 at 23:22

1 Answers1

0

You can use coord_fixed to "reduce" your axis

library(dplyr)
library(ggplot2)

data.frame(x = c(1,2,3,4), size = c(1,1,4,8)) %>% 
  ggplot(aes(x=x, y=1, size = size)) +
  geom_point(alpha=0.5, shape=19) +
  scale_size(range = c(.1, 24)) +
  scale_y_continuous(breaks = NULL)+
  coord_fixed(6)

enter image description here

Vinícius Félix
  • 8,448
  • 6
  • 16
  • 32