ternary_fap() draws either a static or interactive ternary diagram, in english or spanish. It is a base diagram where data can be plotted.
Details
For plotting data on the ggplot object it would be easier if the names of the dataframe are "p", "f", and "a", that way it gets mapped automatically, if not make sure to use "aes(x=p,y=f,z=a)".
For plotting on the plotly object the mapping of the new data should be as shown in the example: a = ~f, b = ~p, c = ~a, where a refers to the top ("f"), b refers to the bottom left ("p"), and c refers to the bottom right ("a").
The examples show basic usage and how to add data, which can be more customizable.
See also
Other classification plots, petrology:
TAS(),
ternary_afm(),
ternary_dickinson_qmflt(),
ternary_dickinson_qtfl(),
ternary_feldspars(),
ternary_folk_gsm(),
ternary_folk_qfl(),
ternary_folk_qfm(),
ternary_folk_smc(),
ternary_pyroclastic_size(),
ternary_pyroclastic_type(),
ternary_qap(),
ternary_qap_g(),
ternary_qap_m_hbl(),
ternary_qap_m_ol(),
ternary_qap_um(),
ternary_qap_um_hbl()
Examples
library(ggplot2)
library(plotly)
d = data.frame(f=c(23,40,60),
p=c(27,50,30),
a=c(50,10,10))
# adding data to ggplot object
ternary_fap() + geom_point(data = d)
#> Warning: Removing Layer 2 ('PositionNudge'), as it is not an approved position (for ternary plots) under the present ggtern package.
#> Ignoring unknown labels:
#> • T : "F"
#> • L : "P"
#> • R : "A"
# adding data to plotly object
ternary_fap('plotly') %>%
add_trace(a = ~f, b = ~p, c = ~a,
data = d,
name = 'My data',
type = "scatterternary",
mode = "markers",
marker = list(size=8,color='coral',
symbol=3,opacity=.9),
hovertemplate = paste0('F: %{a}<br>',
'P: %{b}<br>',
'A: %{c}'))