Counting overlapping points in ggtern?

82 Views Asked by At

I'm working on a script to display the degree to which plant species grow in 3 different categories in a ternary plot but my biggest problem is, that all of the points overlap completely with other points, sometimes little sometimes a lot. I want to count them and have all amounts in my legend, preferably with different shapes or sizes displayed in the plot. The issue here is, that I am relatively inexperienced with R and only get so far, that I have 3 categories, them being 50,100 and 150. Is what I want even possible?

My code so far:

ggtern(data=Anthurium_R, aes(x=Epiphytic, y=Lithophytic, z=Terrestrial)) +
  geom_mask() + 
  geom_point(alpha=0.15, size=5, shape=4, color="blue") + 
  geom_count(mapping = NULL, data = NULL, stat = "sum", position = "identity",na.rm = FALSE, show.legend = NA, inherit.aes = TRUE) +
  scale_size_area(max_size = 4) +
  limit_tern() +
  labs(title = "Plant life form distribtuion for clusiaceae") + 
  theme_arrowlarge() +
  theme(plot.title = element_text(hjust = 0.5))

The plot:

enter image description here

Edit: Now that I read a bit more about geom_count, basically what I want is an "n" for every point and if possible I would like to rename n to "Number of plants"

0

There are 0 best solutions below