---
output:
html_document:
code_folding: hide
---
```{r block2, warning=FALSE, message=FALSE, fig.width=8, fig.height=6.5, dev='svg'}
library(ggtern)
library(ggalt)
data("Fragments")
base = ggtern(Fragments,aes(Qm,Qp,Rf+M,fill=GrainSize,shape=GrainSize)) +
theme_bw() + theme_legend_position('tr') +
geom_encircle(alpha=0.5,size=1) + geom_point(size=2.5) +
labs(title = "Example Plot", subtitle = "using geom_encircle") +
guides(fill = guide_legend(override.aes = list(linetype = 0)),
color = guide_legend(override.aes = list(linetype = 0)))
df.vp = data.frame(x = c(.5,1,0,0,1), y = c(.5,1,0,1,0),
label = c('Middle','Top Right','Bottom Left','Top Left','Bottom Right'))
base3 = base +
theme(legend.position = 'right') +
geom_mask() +
geom_label_viewport(data=df.vp,aes(x=x,y=y,label=label,color=label),inherit.aes = FALSE) +
labs(color = "Label", subtitle = "using geom_label_viewport")
base3