I have a dataset like this:
DENSE<-runif(10, min=0, max=100)
CROP<-runif(10, min=0, max=100)
WILD<-runif(10, min=0, max=100)
BetaDiv<-runif(10, min=0, max=1)
df<-data.frame(DENSE, CROP, WILD, BetaDiv)
I use this code to do a simple ternary plot,
ggtern(df[ordered(-df$BetaDiv),],aes(DENSE,CROP,WILD))+
geom_point(alpha=0.8, aes(color=BetaDiv), size=3)+ scale_color_viridis_c(direction = -1)+
stat_density_tern(geom = 'polygon',
n = 100,
aes(fill = ..level..,
alpha = ..level..))
However, I need the density to be given by the variable BetaDiv. That is, that the density shows me where the BetaDiv values are concentrated.
Thanks to every one.
RS.
