LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Ternary / TriPlot Help

Hello Everybody..
Can somebody help me with the development of a 'Ternary/Tri plot'. I am not sure if CVI has any libraries which would help me create one.
It would be a great help if someone has the code for developing this.
Best regards
Dwivedi
0 Kudos
Message 1 of 2
(3,036 Views)
Hello,

There isn't a built-in function to display triplots (2D triangular plots). One option would be to find a C third-party library or function and call it within CVI.

A basic implementation of triplots in CVI would involve using the PlotPolygon function.
First you would have two 1D arrays - one for the X values of the triangles and one for the Y values of the triangles
Then, you would have a 2D M x 3 array. Each row would contains indices into the vectors x and y that define a single triangle.

Use the indices in each column of the 2D array to index into the X and Y arrays. Then pass the resulting value into the PlotPolygon function.

void TriPlot () {
int x [100];
int y [100];
int m [3][5];
int i, j = 0;

int xArray[3];
int yArray[3];

for (i = 0; i < 100; i++) {
x [i] = Random(0, 50);
y [i] = Random(0, 50);
}

for (i = 0; i < 3; i++)
for (j = 0; j < 5; j++)
m[i][j] = Random(0, 99);

for (i = 0; i < 5; i++) {
xArray[0] = x[m[0][i]];
xArray[1] = x[m[1][i]];
xArray[2] = x[m[2][i]];

yArray[0] = y[m[0][i]];
yArray[1] = y[m[1][i]];
yArray[2] = y[m[2][i]];

PlotPolygon (panelHandle, PANEL_GRAPH, xArray, yArray, 3, VAL_INTEGER, VAL_INTEGER, VAL_RED, VAL_TRANSPARENT);
}

}

The above code creates random triangles, but you could generate the triangle points by your particular algorithm (to make the equilateral, etc).

I hope that helps.
Wendy L
LabWindows/CVI Developer Newsletter
0 Kudos
Message 2 of 2
(3,025 Views)