Title: | Ternary Plots |
Version: | 1.4.0 |
Maintainer: | Nicolas Frerebeau <nicolas.frerebeau@u-bordeaux-montaigne.fr> |
Description: | Ternary plots made simple. This package allows to create ternary plots using 'graphics'. It provides functions to display the data in the ternary space, to add or tune graphical elements and to display statistical summaries. It also includes common ternary diagrams which are useful for the archaeologist (e.g. soil texture charts, ceramic phase diagram). |
License: | GPL (≥ 3) |
URL: | https://codeberg.org/tesselle/isopleuros, https://packages.tesselle.org/isopleuros/ |
BugReports: | https://codeberg.org/tesselle/isopleuros/issues |
Depends: | R (≥ 3.5) |
Imports: | graphics, grDevices, methods, stats, utils |
Suggests: | interp, rsvg, svglite, tinysnapshot, tinytest |
Encoding: | UTF-8 |
LazyData: | true |
RoxygenNote: | 7.3.2 |
X-schema.org-applicationCategory: | Archaeological Science |
X-schema.org-isPartOf: | https://www.tesselle.org |
X-schema.org-keywords: | archaeometry, archaeological-science, ternary-plot, data-visualization, r-package |
Collate: | 'AllGenerics.R' 'coordinates.R' 'data.R' 'isopleuros-internal.R' 'isopleuros-package.R' 'ternary_arrows.R' 'ternary_axes.R' 'ternary_box.R' 'ternary_contour.R' 'ternary_crosshairs.R' 'ternary_density.R' 'ternary_ellipse.R' 'ternary_grid.R' 'ternary_hull.R' 'ternary_image.R' 'ternary_labels.R' 'ternary_lines.R' 'ternary_mean.R' 'ternary_pairs.R' 'ternary_pca.R' 'ternary_plot.R' 'ternary_points.R' 'ternary_polygon.R' 'ternary_segments.R' 'ternary_text.R' 'ternary_title.R' 'ternary_window.R' 'triangle_phase.R' 'triangle_soil.R' 'zzz.R' |
NeedsCompilation: | no |
Packaged: | 2025-03-04 15:31:43 UTC; nicolas |
Author: | Nicolas Frerebeau |
Repository: | CRAN |
Date/Publication: | 2025-03-04 16:00:02 UTC |
isopleuros: Ternary Plots
Description
Ternary plots made simple. This package allows to create ternary plots using 'graphics'. It provides functions to display the data in the ternary space, to add or tune graphical elements and to display statistical summaries. It also includes common ternary diagrams which are useful for the archaeologist (e.g. soil texture charts, ceramic phase diagram).
Details
Package: | isopleuros |
Type: | Package |
Version: | 1.4.0 |
License: | GPL-3 |
Zenodo: | doi:10.5281/zenodo.7940389 |
Package options
isopleuros
uses the following options()
to configure behavior:
-
isopleuros.missing
: alogical
scalar. Should missing values be replaced with zeros before the ternary coordinates computation proceeds? IfFALSE
(the default), incomplete cases are removed.
Author(s)
Full list of authors and contributors (alphabetic order)
Nicolas Frerebeau | Université Bordeaux Montaigne, France |
Brice Lebrun | Université Bordeaux Montaigne, France |
Package maintainer
Nicolas Frerebeau
nicolas.frerebeau@u-bordeaux-montaigne.fr
Archéosciences Bordeaux (UMR 6034)
Maison de l'Archéologie
Université Bordeaux Montaigne
33607 Pessac cedex
France
See Also
Useful links:
Report bugs at https://codeberg.org/tesselle/isopleuros/issues
Arctic Lake Sediments Compositions
Description
Sand, silt, clay compositions of 39 sediment samples at different water depths in an Arctic lake.
Usage
arctic
Format
A data.frame
with 4 variables:
- sand
- silt
- clay
- depth
Water depth (m).
Source
Aitchison, J. (1986). The Statistical Analysis of Compositional Data. London: Chapman and Hall. doi:10.1007/978-94-009-4109-0.
See Also
Boxite Compositions
Description
Compositions of 25 specimens of boxite.
Usage
boxite
Format
A data.frame
with 5 variables:
- A
albite.
- B
blandite.
- C
cornite.
- D
daubite.
- E
endite.
Source
Aitchison, J. (1986). The Statistical Analysis of Compositional Data. London: Chapman and Hall. doi:10.1007/978-94-009-4109-0.
See Also
Cartesian Coordinates
Description
Computes cartesian coordinates.
Usage
coordinates_cartesian(x, y, ...)
## S4 method for signature 'numeric,numeric'
coordinates_cartesian(x, y)
## S4 method for signature 'ANY,missing'
coordinates_cartesian(x, xlab = NULL, ylab = NULL)
Arguments
x , y |
A |
... |
Currently not used. |
xlab , ylab |
A |
Value
A list
with the components:
x | A numeric vector of x coordinates. |
y | A numeric vector of y coordinates. |
z | A numeric vector of z coordinates. |
Author(s)
N. Frerebeau
See Also
Other coordinates:
coordinates_ternary()
Examples
## Compositional data
coda <- data.frame(
x = c(1, 0, 0, 1/3),
y = c(0, 1, 0, 1/3),
z = c(0, 0, 1, 1/3)
)
## Ternary coordinates
(tern <- coordinates_ternary(coda))
## Cartesian coordinates
(cart <- coordinates_cartesian(tern))
Ternary Coordinates
Description
Computes ternary coordinates.
Usage
coordinates_ternary(x, y, z, ...)
## S4 method for signature 'numeric,numeric,numeric'
coordinates_ternary(
x,
y,
z,
center = FALSE,
scale = FALSE,
missing = getOption("isopleuros.missing")
)
## S4 method for signature 'ANY,missing,missing'
coordinates_ternary(
x,
xlab = NULL,
ylab = NULL,
zlab = NULL,
center = FALSE,
scale = FALSE,
missing = getOption("isopleuros.missing")
)
Arguments
x , y , z |
A |
... |
Currently not used. |
center |
|
scale |
A |
missing |
A |
xlab , ylab , zlab |
A |
Value
A list
with the components:
x | A numeric vector of x coordinates. |
y | A numeric vector of y coordinates. |
center | A numeric vector giving the center. |
scale | A numeric vector giving the scale factor. |
Author(s)
N. Frerebeau
See Also
Other coordinates:
coordinates_cartesian()
Examples
## Compositional data
coda <- data.frame(
x = c(1, 0, 0, 1/3),
y = c(0, 1, 0, 1/3),
z = c(0, 0, 1, 1/3)
)
## Ternary coordinates
(tern <- coordinates_ternary(coda))
## Cartesian coordinates
(cart <- coordinates_cartesian(tern))
Skye Lavas Compositions
Description
AFM compositions of 23 aphyric Skye lavas.
Usage
lava
Format
A data.frame
with 3 variables:
- A
Na2O + K2O (percent).
- F
Fe2O3 (percent).
- M
MgO (percent).
Source
Aitchison, J. (1986). The Statistical Analysis of Compositional Data. London: Chapman and Hall. doi:10.1007/978-94-009-4109-0.
See Also
Other datasets:
arctic
,
boxite
Add Arrows to a Ternary Plot
Description
Draw arrows between pairs of points.
Usage
ternary_arrows(x0, y0, z0, ...)
## S4 method for signature 'numeric,numeric,numeric'
ternary_arrows(x0, y0, z0, x1 = x0, y1 = y0, z1 = z0, ...)
Arguments
x0 , y0 , z0 |
A |
... |
Further arguments to be passed to |
x1 , y1 , z1 |
A |
Value
ternary_arrows()
is called it for its side-effects.
Author(s)
N. Frerebeau
See Also
Other geometries:
ternary_crosshairs()
,
ternary_image()
,
ternary_labels()
,
ternary_lines()
,
ternary_points()
,
ternary_polygon()
,
ternary_segments()
,
ternary_text()
Examples
## Add arrows
ternary_plot(NULL, panel.first = ternary_grid())
ternary_arrows(x0 = 40, y0 = 20, z0 = 40,
x1 = 20, y1 = 40, z1 = 40)
Add an Axis to a Ternary Plot
Description
Adds an axis to the current plot.
Usage
ternary_axis(
side,
at = NULL,
labels = TRUE,
tick = TRUE,
center = getOption("isopleuros.center"),
scale = getOption("isopleuros.scale"),
font = NA,
lty = "solid",
lwd = 1,
lwd.ticks = lwd,
col = NULL,
col.ticks = NULL,
...
)
Arguments
side |
An |
at |
A |
labels |
A |
tick |
A |
center |
A |
scale |
A |
font |
font for text. Defaults to |
lty |
A |
lwd , lwd.ticks |
A non-negative |
col , col.ticks |
Colors for the axis line and the tick marks
respectively. Defaults to |
... |
Other graphical parameters may also be passed as
arguments to this function, particularly, |
Value
ternary_axis()
is called it for its side-effects.
Author(s)
N. Frerebeau
See Also
Other graphical elements:
ternary_box()
,
ternary_grid()
,
ternary_pairs()
,
ternary_plot()
,
ternary_title()
Examples
## Add axis
ternary_plot(NULL, axes = FALSE)
ternary_axis(side = 1, col = "red")
ternary_axis(side = 2, col = "blue")
ternary_axis(side = 3, col = "green")
## Add box and grid
ternary_plot(NULL, axes = FALSE)
ternary_box(lty = "dashed", col = "red")
ternary_grid(lty.primary = "dotted")
Draw a Box around a Ternary Plot
Description
Draw a Box around a Ternary Plot
Usage
ternary_box(lty = "solid", ...)
Arguments
lty |
A |
... |
Other graphical parameters may also be passed as
arguments to this function, particularly, |
Value
ternary_box()
is called it for its side-effects.
Author(s)
N. Frerebeau
See Also
Other graphical elements:
ternary_axis()
,
ternary_grid()
,
ternary_pairs()
,
ternary_plot()
,
ternary_title()
Examples
## Add axis
ternary_plot(NULL, axes = FALSE)
ternary_axis(side = 1, col = "red")
ternary_axis(side = 2, col = "blue")
ternary_axis(side = 3, col = "green")
## Add box and grid
ternary_plot(NULL, axes = FALSE)
ternary_box(lty = "dashed", col = "red")
ternary_grid(lty.primary = "dotted")
Contour Lines
Description
Computes and draws contour lines.
Usage
ternary_contour(x, y, z, ...)
## S4 method for signature 'numeric,numeric,numeric'
ternary_contour(
x,
y,
z,
value,
n = 50,
nlevels = 10,
levels = pretty(range(value, na.rm = TRUE), nlevels),
ilr = TRUE,
method = "linear",
extrapolate = FALSE,
palette = function(i) grDevices::hcl.colors(i, "YlOrRd", rev = TRUE),
...
)
## S4 method for signature 'ANY,missing,missing'
ternary_contour(
x,
value,
n = 50,
nlevels = 10,
levels = pretty(range(value, na.rm = TRUE), nlevels),
ilr = TRUE,
method = "linear",
extrapolate = FALSE,
palette = function(i) grDevices::hcl.colors(i, "YlOrRd", rev = TRUE),
...
)
Arguments
x , y , z |
A |
... |
Further arguments to be passed to |
value |
A |
n |
A length-one |
nlevels |
A length-one |
levels |
A |
ilr |
A |
method |
A |
extrapolate |
A |
palette |
A color palette |
Details
Contour are computed from a bivariate interpolation onto a grid, after an isometric log ratio transformation of the original data.
Value
ternary_contour()
is called it for its side-effects.
Invisibly returns a list
with elements levels
(the contour levels) and
colors
(the contour colors) that can be used for a legend.
Note
The interp package needs to be installed on your machine.
Author(s)
N. Frerebeau
See Also
interp::interp()
, grDevices::contourLines()
Other statistics:
ternary_density()
,
ternary_ellipse()
,
ternary_hull()
,
ternary_mean()
,
ternary_pca()
Examples
## Add density
## Data from Aitchison 1986
ternary_plot(arctic, panel.first = ternary_grid())
levels <- ternary_contour(arctic, value = arctic$depth, n = 100, nlevels = 10)
## Add a legend
legend_image <- grDevices::as.raster(rev(levels$colors))
graphics::rasterImage(legend_image, 0.85, 0.75, 0.9, 1)
graphics::text(x = 0.9, y = c(0.75, 1), labels = range(levels$levels), pos = 4)
Add Cross-Hairs to a Ternary Plot
Description
Draw lines that intersect at a point.
Usage
ternary_crosshairs(x, y, z, ...)
## S4 method for signature 'numeric,numeric,numeric'
ternary_crosshairs(x, y, z, x_mark = TRUE, y_mark = TRUE, z_mark = TRUE, ...)
## S4 method for signature 'ANY,missing,missing'
ternary_crosshairs(x, x_mark = TRUE, y_mark = TRUE, z_mark = TRUE, ...)
Arguments
x , y , z |
A |
... |
Further graphical parameters (see |
x_mark , y_mark , z_mark |
A |
Value
ternary_crosshairs()
is called it for its side-effects.
Author(s)
N. Frerebeau
See Also
Other geometries:
ternary_arrows()
,
ternary_image()
,
ternary_labels()
,
ternary_lines()
,
ternary_points()
,
ternary_polygon()
,
ternary_segments()
,
ternary_text()
Examples
## Add cross-hairs
## Data from Aitchison 1986
ternary_plot(lava, panel.first = ternary_grid())
ternary_crosshairs(lava)
ternary_plot(lava, panel.first = ternary_grid())
ternary_crosshairs(lava, y_mark = FALSE, z_mark = FALSE, col = "red")
ternary_plot(lava, panel.first = ternary_grid())
ternary_crosshairs(lava, x_mark = FALSE, z_mark = FALSE, col = "green")
ternary_plot(lava, panel.first = ternary_grid())
ternary_crosshairs(lava, x_mark = FALSE, y_mark = FALSE, col = "blue")
Density Contour Lines
Description
Computes and draws density contour lines.
Usage
ternary_density(x, y, z, ...)
## S4 method for signature 'numeric,numeric,numeric'
ternary_density(
x,
y,
z,
h = NULL,
n = 25,
nlevels = 10,
levels = NULL,
palette = function(i) grDevices::hcl.colors(i, "YlOrRd", rev = TRUE),
...
)
## S4 method for signature 'ANY,missing,missing'
ternary_density(
x,
h = NULL,
n = 25,
nlevels = 10,
levels = NULL,
palette = function(i) grDevices::hcl.colors(i, "YlOrRd", rev = TRUE),
...
)
Arguments
x , y , z |
A |
... |
Further arguments to be passed to |
h |
A length-one |
n |
A length-one |
nlevels |
A length-one |
levels |
A |
palette |
A color palette |
Details
Two-dimensional kernel density estimation with an axis-aligned bivariate normal kernel. Normal kernel is evaluated on a square grid, after an isometric log ratio transformation of the original data.
Value
ternary_density()
is called it for its side-effects.
Invisibly returns a list
with elements levels
(the contour levels) and
colors
(the contour colors) that can be used for a legend.
Note
This must be considered as experimental and subject to major changes in a future release.
Author(s)
N. Frerebeau
Source
Two-dimensional kernel density estimation is adapted from MASS::kde2d()
.
See Also
Other statistics:
ternary_contour()
,
ternary_ellipse()
,
ternary_hull()
,
ternary_mean()
,
ternary_pca()
Examples
## Add density
## Data from Aitchison 1986
ternary_plot(lava, panel.first = ternary_grid())
levels <- ternary_density(lava, n = 500, nlevels = 10)
## Add a legend
legend_image <- grDevices::as.raster(rev(levels$colors))
graphics::rasterImage(legend_image, 0.85, 0.75, 0.9, 1)
graphics::text(x = 0.9, y = c(0.75, 1), labels = range(levels$levels), pos = 4)
Add an Ellipse to a Ternary Plot
Description
Computes and draws a confidence/tolerance ellipse.
Usage
ternary_ellipse(x, y, z, ...)
ternary_confidence(x, y, z, ...)
ternary_tolerance(x, y, z, ...)
## S4 method for signature 'numeric,numeric,numeric'
ternary_ellipse(x, y, z, radius = 1, ...)
## S4 method for signature 'ANY,missing,missing'
ternary_ellipse(x, radius = 1, ...)
## S4 method for signature 'numeric,numeric,numeric'
ternary_confidence(x, y, z, level = 0.95, ...)
## S4 method for signature 'ANY,missing,missing'
ternary_confidence(x, level = 0.95, ...)
## S4 method for signature 'numeric,numeric,numeric'
ternary_tolerance(x, y, z, level = 0.95, ...)
## S4 method for signature 'ANY,missing,missing'
ternary_tolerance(x, level = 0.95, ...)
Arguments
x , y , z |
A |
... |
Further arguments to be passed to |
radius |
A |
level |
A |
Details
Ellipse coordinates are computed after an isometric log ratio transformation of the original data.
Value
ternary_ellipse()
is called it for its side-effects.
Author(s)
N. Frerebeau
See Also
Other statistics:
ternary_contour()
,
ternary_density()
,
ternary_hull()
,
ternary_mean()
,
ternary_pca()
Examples
## Ellipses
## Data from Aitchison 1986
ternary_plot(lava, panel.first = ternary_grid(5, 10))
ternary_tolerance(lava, level = 0.95, border = "blue", lty = 2)
ternary_confidence(lava, level = 0.95, border = "red", lty = 3)
Add Grid to a Ternary Plot
Description
Adds a triangular grid to an existing plot.
Usage
ternary_grid(
primary = NULL,
secondary = NULL,
center = getOption("isopleuros.center"),
scale = getOption("isopleuros.scale"),
col.primary = "darkgray",
col.secondary = "lightgray",
lty.primary = "dashed",
lty.secondary = "dotted",
lwd.primary = 1,
lwd.secondary = lwd.primary
)
Arguments
primary |
An |
secondary |
An |
center |
A |
scale |
A |
col.primary , col.secondary |
A |
lty.primary , lty.secondary |
A |
lwd.primary , lwd.secondary |
A non-negative |
Value
ternary_grid()
is called it for its side-effects.
Author(s)
N. Frerebeau
See Also
Other graphical elements:
ternary_axis()
,
ternary_box()
,
ternary_pairs()
,
ternary_plot()
,
ternary_title()
Examples
## Data from Aitchison 1986
ternary_plot(lava, center = FALSE, scale = FALSE, col = "red", pch = 16)
ternary_grid(5)
## Center
z <- ternary_plot(lava, center = TRUE, col = "blue", pch = 16)
ternary_grid(5, center = z$center)
## Center and scale
z <- ternary_plot(lava, center = TRUE, scale = TRUE, col = "green", pch = 16)
ternary_grid(5, center = z$center, scale = z$scale)
Convex Hull of a Set of Points
Description
Computes and draws the convex hull of the set of points specified.
Usage
ternary_hull(x, y, z, ...)
## S4 method for signature 'numeric,numeric,numeric'
ternary_hull(x, y, z, center = FALSE, scale = FALSE, ...)
## S4 method for signature 'ANY,missing,missing'
ternary_hull(x, center = FALSE, scale = FALSE, ...)
Arguments
x , y , z |
A |
... |
Further arguments to be passed to |
center |
A |
scale |
A |
Value
ternary_hull()
is called it for its side-effects.
Author(s)
N. Frerebeau
See Also
grDevices::chull()
, graphics::polygon()
Other statistics:
ternary_contour()
,
ternary_density()
,
ternary_ellipse()
,
ternary_mean()
,
ternary_pca()
Examples
## Convex hull
## Data from Aitchison 1986
ternary_plot(lava, panel.first = ternary_grid(5, 10))
ternary_hull(lava, border = "red")
Display a Color Image
Description
Creates a grid of colored triangles with colors corresponding to the output of a function.
Usage
ternary_image(f, ...)
## S4 method for signature 'function'
ternary_image(f, n = 48, palette = NULL, ...)
Arguments
f |
A |
... |
Further parameters to be passed to |
n |
A length-one |
palette |
A |
Value
ternary_image()
is called it for its side-effects.
Author(s)
N. Frerebeau
See Also
Other geometries:
ternary_arrows()
,
ternary_crosshairs()
,
ternary_labels()
,
ternary_lines()
,
ternary_points()
,
ternary_polygon()
,
ternary_segments()
,
ternary_text()
Examples
## RGB
ternary_plot(NULL, xlab = "Red", ylab = "Green", zlab = "Blue")
ternary_image(f = rgb, n = 20, palette = FALSE)
Non-Overlapping Text Labels
Description
Optimize the location of text labels to minimize overplotting text.
Usage
ternary_labels(x, y, z, ...)
## S4 method for signature 'numeric,numeric,numeric'
ternary_labels(
x,
y,
z,
center = FALSE,
scale = FALSE,
labels = seq_along(x),
type = c("text", "shadow"),
...
)
## S4 method for signature 'ANY,missing,missing'
ternary_labels(x, center = FALSE, scale = FALSE, labels = seq_along(x$x), ...)
Arguments
x , y , z |
A |
... |
Further graphical parameters (see |
center |
A |
scale |
A |
labels |
A |
type |
A |
Value
ternary_labels()
is called it for its side-effects.
Author(s)
N. Frerebeau
See Also
Other geometries:
ternary_arrows()
,
ternary_crosshairs()
,
ternary_image()
,
ternary_lines()
,
ternary_points()
,
ternary_polygon()
,
ternary_segments()
,
ternary_text()
Examples
## Compositional data
coda <- data.frame(
X = c(41.0, 40, 39.0),
Y = c(19.5, 20, 20.5),
Z = c(39.5, 40, 40.5)
)
## Add text
ternary_plot(NULL, panel.first = ternary_grid())
ternary_points(coda)
ternary_labels(coda, labels = c("A", "B", "C"))
Add Connected Line Segments to a Ternary Plot
Description
Add Connected Line Segments to a Ternary Plot
Usage
ternary_lines(x, y, z, ...)
## S4 method for signature 'numeric,numeric,numeric'
ternary_lines(x, y, z, type = "l", ...)
## S4 method for signature 'ANY,missing,missing'
ternary_lines(x, type = "l", ...)
Arguments
x , y , z |
A |
... |
Further graphical parameters (see |
type |
A |
Value
ternary_lines()
is called it for its side-effects.
Author(s)
N. Frerebeau
See Also
Other geometries:
ternary_arrows()
,
ternary_crosshairs()
,
ternary_image()
,
ternary_labels()
,
ternary_points()
,
ternary_polygon()
,
ternary_segments()
,
ternary_text()
Examples
## Compositional data
coda <- data.frame(
X = c(20, 60, 20, 20),
Y = c(20, 20, 60, 40),
Z = c(60, 20, 20, 40)
)
## Add lines
ternary_plot(NULL, panel.first = ternary_grid())
ternary_lines(coda, col = "red", lwd = 2)
Compositional Mean
Description
Computes and draws the closed geometric mean of the set of points specified.
Usage
ternary_mean(x, y, z, ...)
## S4 method for signature 'numeric,numeric,numeric'
ternary_mean(x, y, z, ...)
## S4 method for signature 'ANY,missing,missing'
ternary_mean(x, y, z, ...)
Arguments
x , y , z |
A |
... |
Further arguments to be passed to |
Value
ternary_mean()
is called it for its side-effects.
Author(s)
N. Frerebeau
See Also
Other statistics:
ternary_contour()
,
ternary_density()
,
ternary_ellipse()
,
ternary_hull()
,
ternary_pca()
Examples
## Mean
## Data from Aitchison 1986
ternary_plot(lava, panel.first = ternary_grid())
ternary_mean(lava, pch = 16, col = "red")
ternary_confidence(lava, level = 0.95, border = "red", lty = 1)
Ternary Plot Matrices
Description
Produces a matrix of ternary plots.
Usage
ternary_pairs(x, ...)
## S4 method for signature 'matrix'
ternary_pairs(x, margin = NULL, ...)
## S4 method for signature 'data.frame'
ternary_pairs(x, margin = NULL, ...)
Arguments
x |
A |
... |
Further graphical parameters. |
margin |
A |
Value
ternary_pairs()
is called it for its side-effects: it results in a graphic
being displayed. Invisibly returns x
.
Author(s)
N. Frerebeau
See Also
Other graphical elements:
ternary_axis()
,
ternary_box()
,
ternary_grid()
,
ternary_plot()
,
ternary_title()
Examples
## Data from Aitchison 1986
## Ternary plots with marginal compositions
ternary_pairs(boxite)
## Ternary plots with endite
ternary_pairs(boxite, margin = "E")
Principal Component Analysis
Description
Computes and draws principal component.
Usage
ternary_pca(x, y, z, ...)
## S4 method for signature 'numeric,numeric,numeric'
ternary_pca(x, y, z, axis = 1, ...)
## S4 method for signature 'ANY,missing,missing'
ternary_pca(x, axis = 1, ...)
Arguments
x , y , z |
A |
... |
Further arguments to be passed to |
axis |
An |
Value
ternary_pca()
is called it for its side-effects.
Author(s)
N. Frerebeau
See Also
Other statistics:
ternary_contour()
,
ternary_density()
,
ternary_ellipse()
,
ternary_hull()
,
ternary_mean()
Examples
## PCA
## Data from Aitchison 1986
ternary_plot(lava, panel.first = ternary_grid())
ternary_pca(lava, axis = 1, col = "red", lty = 2)
Ternary Plot
Description
Produces a ternary plot.
Usage
ternary_plot(x, y, z, ...)
## S4 method for signature 'numeric,numeric,numeric'
ternary_plot(
x,
y,
z,
center = FALSE,
scale = FALSE,
xlim = NULL,
ylim = NULL,
zlim = NULL,
xlab = NULL,
ylab = NULL,
zlab = NULL,
main = NULL,
sub = NULL,
ann = graphics::par("ann"),
axes = TRUE,
frame.plot = axes,
panel.first = NULL,
panel.last = NULL,
...
)
## S4 method for signature 'ANY,missing,missing'
ternary_plot(
x,
xlim = NULL,
ylim = NULL,
zlim = NULL,
xlab = NULL,
ylab = NULL,
zlab = NULL,
main = NULL,
sub = NULL,
ann = graphics::par("ann"),
axes = TRUE,
frame.plot = axes,
panel.first = NULL,
panel.last = NULL,
...
)
Arguments
x , y , z |
A |
... |
Other graphical parameters may also be passed as arguments to this function. |
center |
A |
scale |
A |
xlim |
A length-three |
ylim |
A length-three |
zlim |
A length-three |
xlab , ylab , zlab |
A |
main |
A |
sub |
A |
ann |
A |
axes |
A |
frame.plot |
A |
panel.first |
An an |
panel.last |
An |
Value
ternary_plot()
is called it for its side-effects: it results in a graphic
being displayed. Invisibly returns a list
with the components:
x | A numeric vector of x values. |
y | A numeric vector of y values. |
z | A numeric vector of z values. |
center | A numeric vector giving the center. |
scale | A numeric vector giving the scale factor. |
Author(s)
N. Frerebeau
See Also
Other graphical elements:
ternary_axis()
,
ternary_box()
,
ternary_grid()
,
ternary_pairs()
,
ternary_title()
Examples
## Blank plot
ternary_plot(NULL)
## Compositional data
coda <- data.frame(
X = c(20, 60, 20, 1/3),
Y = c(20, 20, 60, 1/3),
Z = c(60, 20, 20, 1/3)
)
## Ternary plot
ternary_plot(coda, pch = 16, col = "red")
## Add a grid
ternary_plot(coda, panel.first = ternary_grid(5, 10))
## Zoom
ternary_plot(coda, ylim = c(0, 0.4, 0), zlim = c(0, 0, 0.4),
panel.first = ternary_grid())
ternary_plot(coda, xlim = c(0, 0.4, 0), zlim = c(0, 0, 0.4),
panel.first = ternary_grid())
ternary_plot(coda, xlim = c(0.4, 0, 0), ylim = c(0, 0.4, 0),
panel.first = ternary_grid())
## Color according to a supplementary variable
## Data from Aitchison 1986
col <- grDevices::colorRampPalette(c("red", "blue"))(nrow(arctic))
ternary_plot(arctic, panel.first = ternary_grid(), pch = 16, col = col)
Add Points to a Ternary Plot
Description
Add Points to a Ternary Plot
Usage
ternary_points(x, y, z, ...)
## S4 method for signature 'numeric,numeric,numeric'
ternary_points(x, y, z, center = FALSE, scale = FALSE, type = "p", ...)
## S4 method for signature 'ANY,missing,missing'
ternary_points(x, center = FALSE, scale = FALSE, type = "p", ...)
Arguments
x , y , z |
A |
... |
Further graphical parameters (see |
center |
A |
scale |
A |
type |
A |
Value
ternary_points()
is called it for its side-effects. Invisibly returns
a list
with the components:
x | A numeric vector of x values. |
y | A numeric vector of y values. |
z | A numeric vector of z values. |
center | A numeric vector giving the center. |
scale | A numeric vector giving the scale factor. |
Author(s)
N. Frerebeau
See Also
Other geometries:
ternary_arrows()
,
ternary_crosshairs()
,
ternary_image()
,
ternary_labels()
,
ternary_lines()
,
ternary_polygon()
,
ternary_segments()
,
ternary_text()
Examples
## Add points
## Data from Aitchison 1986
ternary_plot(NULL, panel.first = ternary_grid())
ternary_points(lava, col = "red", pch = 16)
## Center and scale
ternary_plot(NULL, axes = FALSE, frame.plot = TRUE)
ternary_points(lava, col = "red", pch = 16)
ternary_points(lava, center = TRUE, col = "blue", pch = 16)
ternary_points(lava, center = TRUE, scale = TRUE, col = "green", pch = 16)
Polygon Drawing
Description
Draws the polygons whose vertices are given in x
, y
and z
.
Usage
ternary_polygon(x, y, z, ...)
## S4 method for signature 'numeric,numeric,numeric'
ternary_polygon(x, y, z, ...)
## S4 method for signature 'ANY,missing,missing'
ternary_polygon(x, y, z, ...)
Arguments
x , y , z |
A |
... |
Further arguments to be passed to |
Value
ternary_polygon()
is called it for its side-effects.
Author(s)
N. Frerebeau
See Also
Other geometries:
ternary_arrows()
,
ternary_crosshairs()
,
ternary_image()
,
ternary_labels()
,
ternary_lines()
,
ternary_points()
,
ternary_segments()
,
ternary_text()
Examples
## Compositional data
coda <- data.frame(
X = c(20, 60, 20),
Y = c(20, 20, 60),
Z = c(60, 20, 20)
)
## Add a polygon
ternary_plot(NULL, panel.first = ternary_grid())
ternary_polygon(coda, density = 5, border = "red")
Add Line Segments to a Ternary Plot
Description
Draw line segments between pairs of points.
Usage
ternary_segments(x0, y0, z0, ...)
## S4 method for signature 'numeric,numeric,numeric'
ternary_segments(x0, y0, z0, x1 = x0, y1 = y0, z1 = z0, ...)
Arguments
x0 , y0 , z0 |
A |
... |
Further graphical parameters (see |
x1 , y1 , z1 |
A |
Value
ternary_segments()
is called it for its side-effects.
Author(s)
N. Frerebeau
See Also
Other geometries:
ternary_arrows()
,
ternary_crosshairs()
,
ternary_image()
,
ternary_labels()
,
ternary_lines()
,
ternary_points()
,
ternary_polygon()
,
ternary_text()
Examples
## Add segments
ternary_plot(NULL, panel.first = ternary_grid())
ternary_segments(x0 = 40, y0 = 20, z0 = 40,
x1 = 20, y1 = 40, z1 = 40)
Add Text to a Ternary Plot
Description
Draws the strings given in the vector labels
at the coordinates given by
x
, y
and z
.
Usage
ternary_text(x, y, z, ...)
## S4 method for signature 'numeric,numeric,numeric'
ternary_text(
x,
y,
z,
center = FALSE,
scale = FALSE,
labels = seq_along(x),
...
)
## S4 method for signature 'ANY,missing,missing'
ternary_text(x, center = FALSE, scale = FALSE, labels = seq_along(x$x), ...)
Arguments
x , y , z |
A |
... |
Further arguments to be passed to |
center |
A |
scale |
A |
labels |
A |
Value
ternary_text()
is called it for its side-effects.
Author(s)
N. Frerebeau
See Also
Other geometries:
ternary_arrows()
,
ternary_crosshairs()
,
ternary_image()
,
ternary_labels()
,
ternary_lines()
,
ternary_points()
,
ternary_polygon()
,
ternary_segments()
Examples
## Compositional data
coda <- data.frame(
X = c(20, 60, 20),
Y = c(20, 20, 60),
Z = c(60, 20, 20)
)
## Add text
ternary_plot(NULL, panel.first = ternary_grid())
ternary_text(coda, labels = c("A", "B", "C"), col = "red", cex = 2)
Ternary Tiles
Description
Compute tile values.
Usage
tile_bin(x, y, z, ...)
tile_density(x, y, z, ...)
tile_interpolate(x, y, z, ...)
## S4 method for signature 'numeric,numeric,numeric'
tile_bin(x, y, z)
## S4 method for signature 'ANY,missing,missing'
tile_bin(x)
## S4 method for signature 'numeric,numeric,numeric'
tile_density(x, y, z)
## S4 method for signature 'ANY,missing,missing'
tile_density(x)
## S4 method for signature 'numeric,numeric,numeric'
tile_interpolate(x, y, z, value, method = "linear", ...)
## S4 method for signature 'ANY,missing,missing'
tile_interpolate(x, value, method = "linear", ...)
Arguments
x , y , z |
A |
... |
Further parameters to be passed to internal methods. |
value |
A |
method |
A |
Value
A function
that takes three numeric
vector as arguments and returns
a numeric
vector.
Author(s)
N. Frerebeau
See Also
Examples
## Data from Aitchison 1986
## Bin
f <- tile_bin(lava)
ternary_plot(NULL)
ternary_image(f = f, n = 12)
## Custom color palette
pal <- function(x) {
x <- (x - min(x)) / (max(x) - min(x)) # Rescale to [0,1]
YlOrBr <- c("#FFFFD4", "#FED98E", "#FE9929", "#D95F0E", "#993404")
RGB <- grDevices::colorRamp(YlOrBr)(x)
grDevices::rgb(RGB, maxColorValue = 255)
}
ternary_plot(NULL)
ternary_image(f = f, n = 12, palette = pal)
## Density
f <- tile_density(lava)
ternary_plot(NULL)
ternary_image(f = f, n = 12, palette = pal)
if (requireNamespace("interp", quietly = TRUE)) {
## Interpolation
f <- tile_interpolate(arctic, value = arctic$depth)
ternary_plot(NULL)
ternary_image(f = f, n = 24, palette = pal)
ternary_points(arctic, col = "red", pch = 16)
}
Ternary Plot Annotation
Description
Ternary Plot Annotation
Usage
ternary_title(
main = NULL,
sub = NULL,
xlab = NULL,
ylab = NULL,
zlab = NULL,
line = NA,
outer = FALSE,
...
)
Arguments
main |
A |
sub |
A |
xlab , ylab , zlab |
A |
line |
Specifying a value for |
outer |
A |
... |
Other graphical parameters may also be passed as
arguments to this function, particularly, |
Value
ternary_title()
is called it for its side-effects.
Author(s)
N. Frerebeau
See Also
Other graphical elements:
ternary_axis()
,
ternary_box()
,
ternary_grid()
,
ternary_pairs()
,
ternary_plot()
Examples
## Add title
ternary_plot(NULL, main = "Main title", sub = "Subtitle",
xlab = "A", ylab = "B", zlab = "C")
ternary_plot(NULL, ann = FALSE)
ternary_title(main = "Main title", sub = "Subtitle",
xlab = "A", ylab = "B", zlab = "C")
Ceramic Phase Diagram
Description
Ceramic Phase Diagram
Usage
triangle_phase_cas(labels = TRUE, symbol = FALSE, mol = FALSE, ...)
triangle_phase_ceramic(labels = TRUE, symbol = FALSE, mol = FALSE, ...)
Arguments
labels |
A |
symbol |
A |
mol |
A |
... |
Further arguments to be passed to |
Author(s)
N. Frerebeau
See Also
Other charts:
triangle_soil
Examples
## Ceramic phase diagram
ternary_plot(NULL, xlab = "CaO", ylab = "Al2O3", zlab = "SiO2")
triangle_phase_ceramic(symbol = TRUE, mol = TRUE, pch = 16)
ternary_plot(NULL, xlab = "CaO", ylab = "Al2O3", zlab = "SiO2")
triangle_phase_ceramic(symbol = TRUE, mol = FALSE, pch = 16)
## CAS diagram
ternary_plot(NULL, axes = FALSE, ann = FALSE, frame.plot = TRUE)
triangle_phase_cas(mol = FALSE, pch = 16)
Soil Texture Triangle
Description
Soil Texture Triangle
Usage
triangle_soil_hypres(labels = TRUE, symbol = FALSE, ...)
triangle_soil_folk(labels = TRUE, symbol = FALSE, ...)
triangle_soil_shepard(labels = TRUE, symbol = FALSE, ...)
triangle_soil_usda(labels = TRUE, symbol = FALSE, ...)
Arguments
labels |
A |
symbol |
A |
... |
Further arguments to be passed to |
Author(s)
N. Frerebeau
See Also
Other charts:
triangle_phase_cas()
Examples
## HYPRES soil texture
ternary_plot(NULL, xlab = "sand", ylab = "silt", zlab = "clay")
triangle_soil_hypres()
## USDA (1951) soil texture
ternary_plot(NULL, xlab = "sand", ylab = "silt", zlab = "clay")
triangle_soil_usda(symbol = TRUE)
## Folk (1954) soil texture
ternary_plot(NULL, xlab = "sand", ylab = "silt", zlab = "clay")
triangle_soil_folk(symbol = TRUE)
## Shepard (1954) soil texture
ternary_plot(NULL, xlab = "sand", ylab = "silt", zlab = "clay")
triangle_soil_shepard()