ternary_pyroclastic: Ternary Diagram for Pyroclastic Rocks

View source: R/ternary_pyroclastic.R

ternary_pyroclasticR Documentation

Ternary Diagram for Pyroclastic Rocks

Description

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

Usage

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

Value

Ternary diagram for pyroclastic rocks in the desired format (object)

Examples

library(ggplot2)
library(plotly)

d = data.frame(lapilli=c(23,26.9,25.3),
               bb=c(27,23.7,5.1),
               ash=c(50,49.4,59.6))

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

# adding data to plotly object
ternary_pyroclastic('plotly') %>%
  add_trace(a = ~bb, b = ~lapilli, c = ~ash,
            data = d,
            name = 'My data',
            type = "scatterternary",
            mode = "markers",
            marker = list(size=8,color='cyan',
                          symbol=3,opacity=.9),
            hovertemplate = paste0('BB: %{a}<br>',
                                   'Lapilli: %{b}<br>',
                                   'Ash: %{c}'))


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