0

I am trying to create a ggplot with a convex hull polygon. The data is the set of isotope values and I wanted to have the values grouped by their source.

The code I used:

ggplot(ff, aes(x=d13C, y=d34S,color=Source,shape=Source)) + geom_point()+ geom_polygon(data = ff,aes(fill =Source,colour =Source),alpha = 0.3,show.legend = TRUE)

But the convex hulls look weird and there are points not included. enter image description here

How can I get the convex hulls corrected?

Bonnie
  • 61
  • 2
  • 1
    It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. Did you calculate the convex hulls yourself first? `geom_polygon` will not do that for you. – MrFlick Jan 28 '22 at 05:36
  • 1
    Does this answer your question? [Adding convex hull to ggplot map](https://stackoverflow.com/questions/48690755/adding-convex-hull-to-ggplot-map) – Julian_Hn Jan 28 '22 at 06:53
  • Thanks for the reply! I didn't calculate the convex hulls first and I think that's the reason. I followed the codes from https://stats.stackexchange.com/a/22855 and it worked. – Bonnie Feb 08 '22 at 04:14

0 Answers0