File Exchange

image thumbnail

Ternary Plots

version 1.0.0.0 (15.9 KB) by Ulrich Theune
Zip file contains program to make different ternary plots.

102 Downloads

Updated 06 Jun 2005

No License

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.

Cite As

Ulrich Theune (2020). Ternary Plots (https://www.mathworks.com/matlabcentral/fileexchange/7210-ternary-plots), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (44)

Hailong Huo

Thank your for this excellent job sharing for us.

Thais Medeiros

Hi, Thank you for sharing the code.
Does someone know how could change the axis limits?
Thanks

Lorenzo BYRDE

Excellent code ! Did exactly what I wanted to do.

Helen chen

Negar Sani

Susana Silva

Hi, great code. My variables have different ranges. It is possible to change the axis limits? Thank you

hongwen li

alok dhaundiyal

Superb

Marcellino D'Avino

first of all excellent job. Just one question, is it possible to change the scale on the axis?

very nice, thanks :)

Madeline Hunt

Nicely commented and easy to follow! Thank you!

Jay Yao

Larry Scipioni

thank you. Wonderful work.

Claire Bossennec

Fatih Taspinar

thanks

shaobin qiu

shaobin qiu

Thanks!!!

Emilie M

Hello, I have a question.
Is it possible to plot some data points in 3D also with ternaryc function ?

My surface is defined :

[hg,htick,hcb]=tersurf(XA,XB,XC,f3);
and then I plot the points:

hold on
[h,hg,htick]=terplot;
colormap(jet)
hter=ternaryc(XA,XB,XC);
set(hter,'marker','o','markerfacecolor','yellow','markersize',4)

Yours sincerely,

Amaneh

Thanks for sharing the code. What should I modify in the code to get the scale 0.2 - 0.4 instead of 0 - 1.0?

Tayler Schweigel

Emir Ahmet OGUZ

Thanks a lot. This code helped me a lot.
I see that some people ask for changing the range of axis, they can simply modify related functions. It takes only a few minutes.

Jay Lefkowitz

Hello All,

I am making a ternary plot of composition with color being Octane number. How do I get the color scaling to be the same for my 3 separate functions?
The intersect points have the same composition thus, the same Octane yet the colors do not match. The data is correct and the values are the same.
Please assist.

UEAuser

How do you input your own data on to this plot?

Haitao Zhang

Terrific!!

Nicolas ARNAUD

Thanks for sharing, nice work!

Nicolas ARNAUD

Delphine S.

Thanks a lot for sharing ;) This is a lot easier with an example!!!! :)

LEI GAO

Hi Ulrich,
Thanks for sharing.

sunshine

Thanks a lot!

basma khaled

Thanks a lot

Leonardo Arief

Leonardo Arief

How can i get this file?

paolo

Thank you

Anderson

These functions relative on the ternary plot are not working at Matlab 2013b.I didn't find "ternary plot" in the "help" of the Matlab 2013b too. Does anybody know what's happening?

Thanks a lot.

Giuseppe

I'm not able to view the file!!

Oscar

Thanks, just thanks

Chemical Engineers like me find this very useful for ternary LLL equilibrium .

Sorry for my English, I am form Colombia.

Olivia Cabrera

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

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

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.

Mary Piche

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

Christoph Rudiger

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

juan guillermo

good

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)

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)

MATLAB Release Compatibility
Created with R13
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

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

Start Hunting!