Jeremy's changes are correct, but there is an additional correction that should be made, as c1 + c2 + c3 should always equal 1.
If input arguments sum to less than one but are not fractional, ternaryc will misrepresent data position because it only reads c1 and c2 for alignment. E.G., ternaryc(0.2,0.1,0.1) plots as though it is 20%, 10%, 70% instead of 50%, 25%, 25%.
To ensure the sum is 1, I added 2 lines and reformatted lines 52-57. New code looks at each line of input data and makes sure it is fractional. If not, fractional values are calculated.
totalc=zeros(size(c1,1),1);
for i=1:size(c1,1)
if max(c1(i)+c2(i)+c3(i))~=1
totalc(i)=c1(i)+c2(i)+c3(i);
c1(i)=c1(i)./(totalc(i));
c2(i)=c2(i)./(totalc(i));
c3(i)=c3(i)./(totalc(i));
end
end
clear totalc
3
25 Apr 2008
Ternary Plots
Zip file contains program to make different ternary plots.
Jeremy Boyce
change lines 52-57 to this:
if max(c1+c2+c3)>1
c1old=c1;c2old=c2;c3old=c3;
c1=c1./(c1old+c2old+c3old)
c2=c2./(c1old+c2old+c3old)
c3=c3./(c1old+c2old+c3old)
end
otherwise you end up using the normalized values to normalize the second and third steps.
2
07 Feb 2008
Ternary Plots
Zip file contains program to make different ternary plots.
Mary Piche
If you try to plot (1,1,1) it is not the same location as seen with Origin 7 ... why?
2
12 Nov 2007
Ternary Plots
Zip file contains program to make different ternary plots.
Christoph Rudiger
Great tool! Just what I was looking for. Also very well commented source code!
Comment only