Home > OS >  Ternary Plot using a vector as density
Ternary Plot using a vector as density

Time:12-01

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..))

enter image description here

  • Related