Ternary plot in MATLAB

Hello all,
I have a .csv file contain 3 columns with 500,000 rows. could you please help me to plot these three columns in one graph, like ternary plot. I already tried to do this by using ternary plot, but due to high number of rows and too much duplicate numbers it is not possible to plot as ternary plot. Each column has different ranges of data. For example the first column's data ranges are from 0.01 to 0.17, the second column 0.045 to 0.96, and the third colum 0 to 100.

Answers (1)

Rik
Rik on 19 Oct 2020
The TrianglePlot function I posted on the FEX seems to work just fine (although I decreased the number of points for this example).
%store the ranges
r_a=[0.01 0.17];
r_b=[0.045 0.96];
r_c=[0 100];
%generate random data - replace this with your actual data
a=rand(500,1);a=r_a(1)+a*diff(r_a);
b=rand(size(a));b=r_b(1)+b*diff(r_b);
c=rand(size(a));c=r_c(1)+c*diff(r_c);
%normalize each variable
a2=(a-r_a(1))/diff(r_a);
b2=(b-r_b(1))/diff(r_b);
c2=(c-r_c(1))/diff(r_c);
points=[a2 b2 c2];
TrianglePlot(points,'--.')

4 Comments

Thanks Rik for your answer. Does your code colorplot? Because I need to have a color ternary plot.I forget to mention in my main question, sorry for that. Just to remind that my data contain 500,000 row with some duplicated numbers.
Rik
Rik on 19 Oct 2020
My function accepts all input options that plot allows, so you can make your plot look exactly like you wish.
You can also use the output to change the appearance of the grid, as the handle to the patch object is included in the output struct.
The fact that your data contains 500000 points is only relevant because you will get a completely filled plot. This is a limitation of wanting all your data in a single image, and not something any function can solve for you. Duplicate values don't realy matter for plot.
Thanks Rik for your time. Actually I am looking for plotting like the attached graph.

Sign in to comment.

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!