No BSD License  

Highlights from
Ternary Plots

3.42857

3.4 | 7 ratings Rate this file 76 Downloads (last 30 days) File Size: 15.93 KB File ID: #7210
image thumbnail

Ternary Plots

by Ulrich Theune

 

20 Mar 2005 (Updated 06 Jun 2005)

Zip file contains program to make different ternary plots.

| Watch this File

File Information
Description

This zip files contains programs (five functions, one example program, and one sample data set) to plot data in ternary diagrams. The first option is a pseudo color plot, the second is a contour plot, and the third style plots the data as color coded symbols (similar to my function 'plot3c'). An additional function is provided to add labels.
The example program (termain.m) shows how to use the functions and how to modify the different plots.

MATLAB release MATLAB 6.5 (R13)
Other requirements Tested with Matlab R13
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (8)
12 May 2005 Tanya Morton

Very useful functionality & a good data set. I've used termain as a geophysics demonstration.
The files could be made slightly more robust to different output data (e.g. it errored with constant data)

17 Nov 2005 Jonathan Victor

Basic functionality is OK, but there is a persistent "
Warning: Color Data is not set for Interpolated shading", and the default tickmarks are very closely spaced (when used in subplots)

01 Feb 2006 juan guillermo

good

12 Nov 2007 Christoph Rudiger

Great tool! Just what I was looking for. Also very well commented source code!

07 Feb 2008 Mary Piche

If you try to plot (1,1,1) it is not the same location as seen with Origin 7 ... why?

25 Apr 2008 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.

09 Nov 2010 Benjamin Hauch

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

09 Apr 2011 Olivia Cabrera

very useful! however, i can't figure out how to change the tick intervals... please help. thanks

Please login to add a comment or rating.
Updates
06 Jun 2005

Added constant data plot to ternaryc() (as suggested by a reviewer).

Tag Activity for this File
Tag Applied By Date/Time
specialized Ulrich Theune 22 Oct 2008 07:43:47
plotting Ulrich Theune 22 Oct 2008 07:43:47
ternary plots Ulrich Theune 22 Oct 2008 07:43:47
data Ulrich Theune 22 Oct 2008 07:43:47
pseudo color Ulrich Theune 22 Oct 2008 07:43:47
special Ulrich Theune 22 Oct 2008 07:43:47
specialized plot Ulrich Theune 22 Oct 2008 07:43:47
graphics Ulrich Theune 22 Oct 2008 07:43:47
ternary plots kuldeep 14 Apr 2009 19:59:55
plotting Sidsel 08 Mar 2012 05:57:41
ternary plots Sidsel 24 Mar 2012 07:48:50

Contact us at files@mathworks.com