Ternary Plots: Setup & Plotting

Ternary Plots

Ayush Noori | EduSTEM Advanced Biology


A ternary plot is a barycentric plot on three variables which sum to a constant. It graphically depicts the ratios of the three variables as positions in an equilateral triangle. In population genetics, it is often called a de Finetti diagram.

Please see the HardyWeinberg package vignette here.


Load the requisite libraries.


Set the working directory to where you would like your output data to result.

dir = "<insert appropriate directory address here>"


AA, AB, and BB are homozygous dominant, heterozygous, and homozygous recessive respectively (i.e. bi-allelic markers). Each row in the column is a different marker or SNP.

Draw random SNPs from a population that is in Hardy-Weinberg Equilibrium.


m = 100 # number of markers
n = 100 # sample size

dat = HWData(n,m)

out = HWTernaryPlot(dat, 100, region=1, vertex.cex=2, signifcolour=TRUE)

In this ternary plot, the center parabola represents the ratio p^2+2pq+p^2, or the Hardy-Weinberg Equilibrium. Red loci differ from the ratio by more than a certain p-value, therefore are considered to NOT be in Hardy-Weinberg Equilibrium.

For more information, please see Hardy-Weinberg Equilibrium and the Ternary Plot by Graffelman and Camarena.

With these courses, we hope to further our mission to make high-quality STEMX education accessible for all. For questions or support, please feel free to reach out to me at anooristudent@outlook.com.

Best Regards,

Ayush Noori

EduSTEM Boston Chapter Founder


  1. NCBI PubMed

The premier source of past and present medical literature. Most supplemental information in Extensions is available via PubMed. When searching PubMed, be sure to use the “Free full text,” and “Sort by: Best Match” filters to find relevant and accessible results.

  1. RCSB Protein Data Bank (PDB)

A large database of useful 3D structures of large biological molecules, including proteins and nucleic acids. Use the search bar to find a molecule of interest, which can then be examined using the Web-based 3D viewer.


1 Like