SharpPlot Tutorials > Chart Samples > Triangle plots for 3-way proportions

Triangle plots for 3-way proportions

The Triangle chart is used to analyse data where there are three important constituents, summing to unity. It is common in Geology and Chemical Engineering where a set of 3 key ingredients determines the outcome from some process.

Plotting the Proportions of 3 values

alpha = new int[] {2,3,3};
bravo = new int[] {3,2,2};
charlie = new int[] {4,4,1};

sp.Heading = "Proportions for 3 Samples";
sp.Subheading = "Requires 3 sets of values as equal-length vectors";

sp.TriangleStyle = (TriangleStyles.Markers|TriangleStyles.Labelled|TriangleStyles.ValueTags|TriangleStyles.GridLines);
sp.XCaption = "Alpha";
sp.YCaption = "Bravo";
sp.ZCaption = "Charlie";
sp.SetValueTags(new string[]{"S1","S2","S3"});


This chart shows the proportions of 3 constituents found in samples S1,S2 and S3. The allocation of series to chart axes is entirely arbitrary – the convention used is to work around clockwise from 12:00.

The natural data structure for this chart is a 3-column matrix, but an array of 3 data arrays (of equal lengths) is accepted.

Illustrating a Danger Zone

methane = new int[] {2,3,3,2,2};
oxygen = new int[] {3,2,2,4,3};
nitrogen = new int[] {4,4,2,2,4};

sp.Heading = "Explosive Mixtures";


sp.TriangleStyle = (TriangleStyles.Lines|TriangleStyles.Curves|TriangleStyles.Labelled|
sp.Flexibility = 12;

sp.XCaption = "Methane";
sp.YCaption = "Oxygen";
sp.ZCaption = "Nitrogen";

sp.SetValueTags(new string[]{"","Danger Area"});
sp.ValueTagStyle = (ValueTagStyles.Inside|ValueTagStyles.Opaque);

sp.DrawTriangle(new int[][]{methane,oxygen,nitrogen});

This is very typical of charts used in the chemical and oil industry, where certain combinations are either desirable or dangerous. Typically a chart such as this would be used as a basis, over which to plot a set of samples.

Note the use of ValueTags (only one is non-null) to label the outline.

See also ...

SharpPlot.DrawTriangle Method

Send comments on this topic
© Dyalog Ltd 2016