ggplot2::scale_size_area() not mapping zero to zero area?

From the documentation of ggplot2::scale_size_area(), I read that

scale_size_area() ensures that a value of 0 is mapped to a size of 0.

However, in this simple example, I still see points where there zeros are. Is this a bug or am I interpreting this wrong?

library(ggplot2)

table(1:3, 1:3) |>
  as.data.frame() |>
  ggplot() +
  aes(x=Var1, y=Var2, size=Freq) +
  geom_point() +
  scale_size_area()

Data

table(1:3, 1:3) |>
  as.data.frame() |>
print()
  Var1 Var2 Freq
1    1    1    1
2    2    1    0
3    3    1    0
4    1    2    0
5    2    2    1
6    3    2    0
7    1    3    0
8    2    3    0
9    3    3    1

Result

enter image description here

the top left dot is associated with size zero, the legend shows that.

to visually eliminate it you could maybe use the alpha channel.

table(1:3, 1:3) |>
  as.data.frame() |>
  ggplot() +
  aes(x=Var1, y=Var2, size=Freq,
      alpha=factor(Freq)) +
  geom_point() +
  scale_size_area()+
  scale_alpha_discrete(guide=NULL,
                       range = c(0,1))

This topic was automatically closed 42 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.