ternary_qap_m: QAP Ternary Diagram for Mafic Rocks

View source: R/ternary_qap_m.R

ternary_qap_mR Documentation

QAP Ternary Diagram for Mafic Rocks

Description

ternary_qap_m() draws either a static or interactive ternary diagram, in english or spanish. It is a base diagram where data can be plotted.

Usage

ternary_qap_m(
  output = c("ggplot", "plotly"),
  language = c("en", "es"),
  opacity = 0.5
)

Arguments

output

The output format: "ggplot" or "plotly" (default is "ggplot")

language

The language to be displayed: "en" for english or "es" for spanish (deafult is "en")

opacity

Transparency level (default is 0.5)

Details

For plotting data on the ggplot object it would be easier if the names of the dataframe are "ol", "p", and "px", that way it gets mapped automatically, if not make sure to use "aes(x=ol,y=p,z=px)". For plotting on the plotly object the mapping of the new data should be as shown in the example: a = ~p, b = ~ol, c = ~px, where a refers to the top ("p"), b refers to the bottom left ("ol"), and c refers to the bottom right ("px"). The examples show basic usage and how to add data, which can be more customizable.

Value

QAP ternary diagram for mafic rocks in the desired format (object)

Examples

library(ggplot2)
library(plotly)

d = data.frame(p=c(23,26.9,25.3),
               ol=c(27,23.7,5.1),
               px=c(50,49.4,59.6))

# adding data to ggplot object
ternary_qap_m() + geom_point(data = d)

# adding data to plotly object
ternary_qap_m('plotly') %>%
  add_trace(a = ~p, b = ~ol, c = ~px,
            data = d,
            name = 'My data',
            type = "scatterternary",
            mode = "markers",
            marker = list(size=8,color='cyan',
                          symbol=3,opacity=.9),
            hovertemplate = paste0('P: %{a}<br>',
                                   'Ol: %{b}<br>',
                                   'Cpx: %{c}'))


maxgav13/GMisc documentation built on June 12, 2022, 3:48 a.m.