File Exchange

image thumbnail

Ternary Plots

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


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 (2021). Ternary Plots (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (48)

Joel Lynch

I recently built an overhauled version of this code to provide more features (such as customized ranges appearance), available here:

Jackson Burns

Dondon Gallentes

hello. is it possible to reverse the axis?

Avishek Rudra

How to make a ternary plot with a specified range of values instead of the entire triangle?

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?

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


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


shaobin qiu

shaobin qiu


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 :

and then I plot the points:

hold on

Yours sincerely,


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.


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

Haitao Zhang


Nicolas ARNAUD

Thanks for sharing, nice work!

Nicolas ARNAUD

Delphine S.

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


Hi Ulrich,
Thanks for sharing.


Thanks a lot!

basma khaled

Thanks a lot

Leonardo Arief

Leonardo Arief

How can i get this file?


Thank you


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.


I'm not able to view the file!!


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.

for i=1:size(c1,1)
if max(c1(i)+c2(i)+c3(i))~=1
clear totalc

Jeremy Boyce

change lines 52-57 to this:

if max(c1+c2+c3)>1

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


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!