stack_mosaic: Stacked mosaic diagram

View source: R/stack_mosaic.R

stack_mosaicR Documentation

Stacked mosaic diagram

Description

Create a stacked mosaic diagram, where the species formed in the first layer become the basis species for the species formed in the second layer. The species in each layer are usually minerals with different metals; any bimetallic species are added to the second layer.

Usage

  stack_mosaic(bases, species1, species2, species12, names = NULL,
    col = list(4, 3, 6), col.names = list(4, 3, 6), fill = NULL,
    dx = list(0, 0, 0), dy = list(0, 0, 0), srt = list(0, 0, 0),
    lwd = list(1, 1, 1), lty = list(1, 1, 1), loga_aq = NULL,
    plot.it = TRUE, ...)

Arguments

bases

basis species to be changed for each layer (commonly S-bearing aqueous species)

species1

species (minerals and/or aqueous species) with metal 1

species2

species with metal 2

species12

bimetallic species

names

character, species names (or chemical formulas) for labeling fields

col

line color

col.names

text color

fill

field color

dx

label x-offset

dy

label y-offset

srt

label rotation

lwd

line width

lty

line type

loga_aq

numeric, activity of aqueous species

plot.it

make plots?

...

arguments for mosaic and affinity

Details

stack_mosaic creates a stacked mosaic diagram following steps that are described in detail in the vignette \viglinkmulti-metal. Briefly, the first layer of the diagram is made by speciating the species in bases across the diagram to form the first set of species in species1. Then, both bases and species1 (the stable species at each point on the diagram) are used to form the second set of species, including those in both species2 and species12.

Note that basis has aqueous S species in the examples provided, and species1 consists of minerals and/or aqueous species with a single metal (e.g. Fe). species2 has minerals and/or aqueous species with a second metal (e.g. Cu), and species12 has bimetallic minerals. For “mixed” diagrams (where species1 or species2 has both minerals and aqueous species), use loga_aq to set the logarithms of activities of aqueous species. Here, only a single value of loga_aq is needed, unlike in mosaic, where a value for each set of basis species is required.

The plot parameters col, col.names, fill, dx, dy, srt, lwd, and lty should be length-3 lists (not vectors). The values of elements 1–3 of the list are recycled to the number of species in species1, species2, and species12, respectively.

For fill, the default is to use no fill except for species12, where the fill color is taken from col.names with added transparency. The default definition of fill is list(NA, NA, add.alpha(col.names[3], "50")).

Value

A list of length two containing the output of each of the diagram calls use to make the diagram.

Warning

The bimetallic species in species12 are shown as part of the second layer, although their formation is sensitive to the presence of stable species in the first layer. It follows that changing the order of layers (i.e., swapping species1 and species2) can affect the depiction of mineral assemblages that have species12. It is likely that only one of the alternatives is thermodynamically correct, but currently there is no check to determine which one it is.

Examples

# Define temperature (degrees C), pressure (bar), pH and logfO2 ranges
T <- 200
P <- "Psat"
res <- 200
pH <- c(0, 14, res)
O2 <- c(-48, -33, res)

# Define system: Fe-Cu-O-S-Cl
# NOTE: the basis species must include the first species listed
# in each of bases, species1, and species2 below
basis(c("pyrite", "Cu", "Cl-", "H2S", "H2O", "oxygen", "H+"))
basis("H2S", -2)
# Calculate solution composition for 1 mol/kg NaCl
NaCl <- NaCl(T = T, P = P, m_tot = 1)
basis("Cl-", log10(NaCl$m_Cl))

# Define arguments for stack_mosaic: Speciate aqueous sulfur
bases <- c("H2S", "HS-", "HSO4-", "SO4-2")
# Calculate stabilities of Fe-bearing minerals first
species1 <- c("pyrite", "pyrrhotite", "magnetite", "hematite")
# Calculate stabilities of Cu-bearing and FeCu-bearing minerals second
species2 <- c("copper", "cuprite", "tenorite", "chalcocite", "covellite")
species12 <- c("chalcopyrite", "bornite")
# Use abbreviations for Fe-bearing minerals and formulas for Cu-bearing minerals
names1 <- c("Py", "Po", "Mag", "Hem")
names2 <- info(info(species2))$formula
names12 <- info(info(species12))$formula
names <- list(names1, names2, names12)
# Adjust x-position for one species (chalcocite, Cu2S)
dx <- list(c(0, 0, 0, 0), c(0, 0, 0, 1, 0), c(0, 0))
# Use thick dashed lines for the bimetallic species
lwd <- list(1, 1, 2)
lty <- list(1, 1, 2)

# Make the diagram
stack_mosaic(bases, species1, species2, species12, names = names,
  dx = dx, lwd = lwd, lty = lty,
  pH = pH, O2 = O2, T = T, P = P, IS = NaCl$IS)
# Add legend and title
lTP <- lex(lTP(T, P))
db <- describe.basis(c(3:4))
legend("topright", c(lTP, db), bg = "white")
title("Fe-Cu-S-O-H-Cl", font.main = 1)

CHNOSZ documentation built on March 31, 2023, 7:54 p.m.