mango.application.plot.ternaryPlot

mango.application.plot.ternaryPlot(data, scaling=True, startAngle=89.9, rotateLabels=True, labels=('one', 'two', 'three'), sides=3, labelOffset=0.0666, edgeArgs={'color': 'black', 'linewidth': 2}, figArgs={'edgecolor': 'white', 'facecolor': 'white', 'figsize': (8, 8)})[source]

This will create a basic ternary plot (or quaternary, quinternary, etc.) Converts ternary data to normalized for for plotting on the returned axes.

Parameters:
  • data ((N,3) shaped numpy.array) – Data to be plotted. A (N,3) shaped numpy.array, where N is the number of data points.
  • scaling (bool) – Scale data for ternary plot (i.e. a + b + c = 1)
  • startAngle (float) – Direction of first vertex.
  • rotateLabels (bool) – Orient labels perpendicular to vertices.
  • labels (sequence of str) – Labels for vertices.
  • sides (int) – Can accommodate more than 3 dimensions if desired.
  • labelOffset (float) – Offset for label from vertex (percent of distance from origin).
  • edgeArgs (dict) – Any matplotlib keyword args for plots.
  • figArgs (dict) – Any matplotlib keyword args for figures.
Return type:

(numpy.array, TernaryAxes)

Returns:

A (N,3) shaped numpy.array, coordinates are transformed to triangular axes.

For example:

from matplotlib.pylab import *
from mango.application.plot import ternaryPlot

k = 0.5
s = 1000

data = vstack((
    array([k,0,0]) + rand(s,3), 
    array([0,k,0]) + rand(s,3), 
    array([0,0,k]) + rand(s,3)
))
color = array([[1,0,0]]*s + [[0,1,0]]*s + [[0,0,1]]*s)

newdata, ternAx = ternaryPlot(data)

ax, fig = ternAx.createAxes()
ax.scatter(
    newdata[:,0],
    newdata[:,1],
    s=2,
    alpha=0.5,
    color=color
)
show()

Previous topic

mango.application.plot.TernaryAxes.createAxes

Next topic

mango.application.plot.TernaryAxes

This Page