Skip to contents

ternary_pyroclastic_type() 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_type(
  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)

Value

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

Details

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

The ternary diagram for pyroclastic rocks based on type is used in volcanology and sedimentary petrology to classify pyroclastic deposits based on the relative proportions of different components, specifically lithic fragments, glass, and crystals. The diagram helps to infer the eruptive style and depositional processes of volcanic eruptions, as different types of eruptions produce characteristic component distributions in the resulting pyroclastic deposits. For a more complete description on how to use this function and similar ones, see vignette("classification_diagrams_vig")

Examples

library(ggplot2)
library(plotly)

d = data.frame(l=c(23,40,60),
               g=c(27,50,30),
               c=c(50,10,10),
               loc=c("A", "B", "C"))

# adding data to ggplot object
ternary_pyroclastic_type() + geom_point(aes(col = loc), data = d)
#> Ignoring unknown labels:
#>  T : "Rock fragments"
#>  L : "Glass"
#>  R : "Crystals"


# adding data to plotly object
ternary_pyroclastic_type('plotly') %>%
  add_trace(a = ~l, b = ~g, c = ~c,
            data = d,
            name = 'My data',
            type = "scatterternary",
            mode = "markers",
            marker = list(size=8,color='cyan',
                          symbol=3,opacity=.9),
            hovertemplate = paste0('Rock fragments: %{a}<br>',
                                   'Glass: %{b}<br>',
                                   'Crystals: %{c}'))
# adding data to plotly object with custom colors my_pal <- c("A" = "red", "B" = "blue", "C" = "green") my_shapes <- c("A" = "circle", "B" = "square", "C" = "diamond") ternary_pyroclastic_type('plotly') %>% add_trace(a = ~l, b = ~g, c = ~c, data = d, type = "scatterternary", mode = "markers", split = ~loc, marker = list(size=8, color = ~my_pal[loc], symbol = ~my_shapes[loc], opacity=.9), hovertemplate = paste0('Rock fragments: %{a}<br>', 'Glass: %{b}<br>', 'Crystals: %{c}'))