ternary_folk: Folk's Ternary Diagram for Sandstones

View source: R/ternary_folk.R

ternary_folkR Documentation

Folk's Ternary Diagram for Sandstones

Description

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

Usage

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

Value

Folk's ternary diagram for sandstones in the desired format (object)

Examples

library(ggplot2)
library(plotly)

d = data.frame(q=c(23,26.9,25.3),
               f=c(27,23.7,5.1),
               r=c(50,49.4,59.6))

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

# adding data to plotly object
ternary_folk('plotly') %>%
  add_trace(a = ~q, b = ~f, c = ~r,
            data = d,
            name = 'My data',
            type = "scatterternary",
            mode = "markers",
            marker = list(size=8,color='coral',
                          symbol=3,opacity=.9),
            hovertemplate = paste0('Q: %{a}<br>',
                                   'F: %{b}<br>',
                                   'R: %{c}'))


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