ggtern, An extension to ggplot2, for the creation of ternary diagrams.
ggtern
is a package that extends the functionality of ggplot2, giving the capability to plot ternary diagrams for (subset of) the ggplot2 proto geometries. Ternary diagrams are used frequently in a number of disciplines to graph compositional features for mixtures of three different elements or compounds. It is possible to represent a coordinate system having three (3) degrees of freedom, in 2D space, since the third dimention is linear and depends only on the other two.
ggtern
is a package that is based on (extends) the very popular ggplot2, which is an implementation of Wilkinsons The Grammar of Graphics, and, makes provision for a highly methodical construction process for the development of meaningful (graphical) data representations. Of course, the above book by Wilkinson outlines the theory, whilst Hadley Wickhams ggplot2 implementation is where much of the magic happens, and, an ideal base-platform for ggtern
.
Install the latest release on CRAN, install just like any other R package:
install.packages('ggtern')
To install the development / working version, use the devtools
package:
devtools::install_git('https://bitbucket.org/nicholasehamilton/ggtern')
Please cite this package as follows:
citation('ggtern')
##
## To cite package 'ggtern' in publications use:
##
## Nicholas Hamilton (2018). ggtern: An Extension to 'ggplot2', for
## the Creation of Ternary Diagrams. R package version 2.2.2.
## https://CRAN.R-project.org/package=ggtern
##
## A BibTeX entry for LaTeX users is
##
## @Manual{,
## title = {ggtern: An Extension to 'ggplot2', for the Creation of Ternary Diagrams},
## author = {Nicholas Hamilton},
## year = {2018},
## note = {R package version 2.2.2},
## url = {https://CRAN.R-project.org/package=ggtern},
## }
Introductory material
ggtern_package
(ggtern-package)ggtern
(constructor)ggplot
(ggplot.data.frame, ggplot.default, plot.ggplot, print.ggplot)Definitions for the ternary coordinate system.
coord_tern
(CoordTern)Definitions for the ternary axes.
scale_X_continuous
(scale_L_continuous, scale_R_continuous, scale_T_continuous)tern_limits
(limit_tern, limits_tern, tern_limit)Information on the layers which are available and approve for use.
approved_layers
(approved_geom, approved_position, approved_stat)Geoms, short for geometric objects, describe the type of plot you will produce. Several of the geoms are accompanied by dedicated stats.
geom_crosshair_tern
(GeomCrosshairTern, GeomLmark, GeomRmark, GeomTmark, geom_Lmark, geom_Rmark, geom_Tmark)geom_confidence_tern
(GeomConfidenceTern, GeomMeanEllipse, StatConfidenceTern, geom_confidence, stat_confidence, stat_confidence_tern)geom_density_tern
(GeomDensityTern, StatDensityTern, stat_density_tern)geom_interpolate_tern
(GeomInterpolateTern, StatInterpolateTern, stat_interpolate_tern)geom_Xline
(GeomLline, GeomRline, GeomTline, Lline, Rline, Tline, geom_Lline, geom_Rline, geom_Tline, lline, rline, tline)geom_Xisoprop
(GeomLisoprop, GeomRisoprop, GeomTisoprop, geom_Lisoprop, geom_Risoprop, geom_Tisoprop)geom_errorbarX
(GeomErrorbarl, GeomErrorbarr, GeomErrorbart, geom_errorbarL, geom_errorbarR, geom_errorbarT)geom_smooth_tern
(GeomSmoothTern, StatSmoothTern, stat_smooth_tern)geom_point_swap
(GeomPointSwap)geom_mask
(GeomMask)geom_label_viewport
(GeomLabelViewport)geom_text_viewport
(GeomTextViewport)geom_mean_ellipse
(StatMeanEllipse, stat_mean_ellipse)geom_hex_tern
(GeomHexTern, GeomTriTern, StatHexTern, stat_hex_tern)geom_tri_tern
(StatTriTern, stat_tri_tern)geom_polygon_closed
(GeomPolygonClosed)Specialised functions for adding annotations to a plot.
annotate
annotation_raster_tern
(GeomRasterAnnTern)Position adjustments can be used to fine tune positioning of objects to achieve effects like dodging, jittering and stacking.
position_nudge_tern
(PositionNudgeTern)position_jitter_tern
(PositionJitterTern)Various calculation routines.
ternary_transformation
(tlr2xy, xy2tlr)mahalanobis_distance
New theme elements, unique to ggtern.
theme
theme_elements
Complete themes available for use.
theme_complete
ggtern_themes
(theme_bluedark, theme_bluelight, theme_bvbg, theme_bvbw, theme_bw, theme_classic, theme_custom, theme_dark, theme_darker, theme_ggtern, theme_gray, theme_light, theme_linedraw, theme_matrix, theme_minimal, theme_rgbg, theme_rgbw, theme_tropical, theme_void)Functions for the rapid customization of plot appearance.
theme_convenience_functions
(convenience_functions, theme_convenience)theme_arrowlength
(theme_arrowcustomlength, theme_arrowdefault, theme_arrowlarge, theme_arrowlong, theme_arrownormal, theme_arrowshort, theme_arrowsmall)theme_gridsontop
(theme_gridsonbottom)theme_bordersontop
(theme_bordersonbottom)theme_clockwise
(tern_anticlockwise, tern_clockwise, tern_counterclockwise, theme_anticlockwise, theme_counterclockwise)theme_legend_position
theme_noarrows
(theme_hidearrows, theme_showarrows)theme_nomask
(theme_hidemask, theme_showmask)theme_novar_tern
theme_rotate
theme_showgrid
(theme_hidegrid, theme_hidegrid_major, theme_hidegrid_minor, theme_nogrid, theme_nogrid_major, theme_nogrid_minor, theme_showgrid_major, theme_showgrid_minor, theme_tern_nogrid, theme_tern_nogrid_major, theme_tern_nogrid_minor)theme_showlabels
(theme_hidelabels, theme_nolabels)theme_showprimary
(theme_hideprimary, theme_hidesecondary, theme_hideticks, theme_noprimary, theme_nosecondary, theme_noticks, theme_showsecondary, theme_showticks)theme_showtitles
(theme_hidetitles, theme_notitles)theme_ticksoutside
(theme_ticksinside)theme_ticklength
(theme_ticklength_major, theme_ticklength_minor)theme_mesh
theme_latex
(theme_hidelatex, theme_nolatex, theme_showlatex)theme_zoom_X
(theme_zoom, theme_zoom_L, theme_zoom_M, theme_zoom_R, theme_zoom_T, theme_zoom_center)Ternary-specific Labels.
ggtern_labels
(Larrowlab, Llab, Rarrowlab, Rlab, Tarrowlab, Tlab, Wlab, ggtern-labels, larrowlab, llab, rarrowlab, rlab, tarrowlab, tlab, wlab, zlab)ggtern_labels_arrow_suffix
(atomic_percent, custom_percent, percent_atomic, percent_custom, percent_weight, weight_percent)label_formatter
breaks_tern
(getBreaks)labels_tern
(getLabels)The following datasets have been included in the present package.
data_Feldspar
(Feldspar, FeldsparRaster)data_Fragments
(Fragments)data_USDA
(USDA)data_WhiteCells
(WhiteCells)data_SkyeLava
(SkyeLava)Functions related to the renderin of legend keys.
draw_key_tern
(draw_key_Liso, draw_key_Lline, draw_key_Lmark, draw_key_Riso, draw_key_Rline, draw_key_Rmark, draw_key_Tiso, draw_key_Tline, draw_key_Tmark, draw_key_crosshair_tern, draw_key_point_swap)The following funcions are useful for saving and printing.
arrangeGrob
(grid.arrange)ggsave
(grid.draw.ggplot)+.gg
(%+%)aes
predictdf2d
strip_unapproved
zzz-depreciated
(clipPolygons, element_ternary, ggtern.multi, multi, multiplot, point.in.sequence, polyclip, tern_stop, theme_arrowbaseline)