ternary_qap_um: QAP Ternary Diagram for Ultramafic Rocks

View source: R/ternary_qap_um.R

ternary_qap_umR Documentation

QAP Ternary Diagram for Ultramafic Rocks

Description

ternary_qap_um() 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_um(
  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 "opx", "ol", and "cpx", that way it gets mapped automatically, if not make sure to use "aes(x=opx,y=ol,z=cpx)". For plotting on the plotly object the mapping of the new data should be as shown in the example: a = ~ol, b = ~opx, c = ~cpx, where a refers to the top ("ol"), b refers to the bottom left ("opx"), and c refers to the bottom right ("cpx"). The examples show basic usage and how to add data, which can be more customizable.

Value

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

Examples

library(ggplot2)
library(plotly)

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

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

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


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