library(ggtern)
## Warning: package 'ggtern' was built under R version 3.2.3
## Loading required package: ggplot2
## Warning: package 'ggplot2' was built under R version 3.2.3
##
## Attaching package: 'ggtern'
##
## The following objects are masked from 'package:ggplot2':
##
## aes, calc_element, ggplot, ggplot_build, ggplot_gtable,
## ggplotGrob, ggsave, is.ggplot, layer_data, layer_grob,
## layer_scales, theme, theme_bw, theme_classic, theme_dark,
## theme_get, theme_gray, theme_light, theme_linedraw,
## theme_minimal, theme_set, theme_void
With own dataset including 3 parameters from 3 countries
library(ggtern)
# Load data
data(Feldspar)
head(Feldspar)
## Experiment Feldspar Ab Or An T.C P.Gpa
## 17 G5 Alkalai 0.333 0.657 0.010 700 0.3
## 18 A4 Alkalai 0.331 0.658 0.011 700 0.3
## 20 G10-9 Alkalai 0.232 0.763 0.005 650 0.3
## 38 A4 Plagioclase 0.763 0.072 0.165 700 0.3
## 40 G10-9 Plagioclase 0.772 0.060 0.168 650 0.3
## 7 K1 Alkalai 0.282 0.700 0.018 800 0.2
df <- data.frame(country = c("POL", "SWE", "ENG"), population = c(70, 15, 100), salary = c(70, 92, 80),
live = c(54, 78, 65 ))
# Sort it by decreasing pressure
# (so small grobs sit on top of large grobs
df = df[with(df, order(-population)), ]
# Build and Render the Plot
ggtern(data = df, aes(x = population, y = salary, z = live)) +
#the layer
geom_point(aes(size = live, color = country), df) +
ggtitle("Example")
#there are more possibiliteis to adjust the figure (see some manuals for ggtern and ggplot2)
#example
url <- "http://www.r-bloggers.com/ggtern-2-0-now-available/"
browseURL(url)