Get from Ico-github-logo

Highlights from

  • deg2rad(deg)
  • fractions(A, B, C)
    FRACTIONS normalise ternary data
  • simpletri(N)
    SIMPLETRI return simple triangulation for square datasets
  • ternaxes(majors)
    TERNAXES create ternary axis
  • terncontour(A, B, C, Z, I)
    TERNCONTOUR plot contours on ternary phase diagram
  • terncoords(fA, fB, fC)
    TERNCOORDS calculate rectangular coordinates of fractions on a ternary plot
  • ternlabel(A, B, C)
    TERNLABEL label ternary phase diagram
  • ternpcolor(varargin)
    TERNPCOLOR plot pseudo color diagram on ternary axes
  • ternplot(A, B, C, varargin)
    TERNPLOT plot ternary phase diagram
  • ternsurf(A, B, C, Z)
    TERNSURF plot surface diagram for ternary phase diagram
  • vertexlabel(A, B, C, offset)
    VERTEXLABEL label ternary phase diagram at vertices
  • terndemo.m
    Simple two-d plot
  • View all files
4.6 | 39 ratings Rate this file 133 Downloads (last 30 days) File Size: 228 KB File ID: #2299 Version: 1.1
image thumbnail



Carl Sandrock (view profile)

  • 1 file
  • 4.61111


28 Aug 2002 (Updated )

Plots ternary phase data on a ternary phase diagram.

| Watch this File

File Information

Plot ternary diagrams in Matlab


This file inspired Wilson Solver(), Gtl Jetfuel Ternplot With Neural Network, 3 D Ternplot, Gtl 3 D Ternplot, Entropy Triangle, Schlee.M, Folk S Classification, Starplot, and Shepard Ternary Plot.

MATLAB release MATLAB 7.3 (R2006b)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (49)
08 Nov 2015 Daniel Choukroun  
25 Sep 2015 Xinlei Huang  
30 Aug 2015 Carl Sandrock

Carl Sandrock (view profile)

  • 1 file
  • 4.61111

Hi @kanes, you should be able to plot bultiple lines using "hold" and ternplot as in normal 2d plots. Perhaps you can post an issue with some sample code on the github repository for this project?

Comment only
29 Aug 2015 kanes

kanes (view profile)

It is a great function, it is very helpful! Thank you very much!

I would like to know how to draw more than one graph on the same figure with a loop . because I tried to use 'for-loop', but there was no more scale and the boundary after plotting.

Reagard and thanks for your time!

24 Jul 2015 cheng joylin  
24 Jul 2015 cheng joylin  
21 May 2015 Carl Sandrock

Carl Sandrock (view profile)

  • 1 file
  • 4.61111

I have started a GitHub repository for this project - you can register feature requests there.

Comment only
04 Feb 2015 Brett Sanders

Thanks for the function. One problem I am experiencing is that the labeling produced by "vertexlabel" is not consistent with the placement by "ternplot". I presently use the following code to place the labels in the right spot:


Have others experienced this problem? Can it be corrected?

Comment only
28 Aug 2014 Elizabeth Jones

Elizabeth Jones (view profile)

  • 1 file
  • 4.66667

Great function, thanks for putting this up. It worked right away, without any tweaking, which is not always the case for files on FileExchange but is always much appreciated. One feature that I did not see right away is the ability to set the size and style of the tick mark labels and axis labels, i.e. change from size 10 to size 12, make bold, etc. I had to go and select each tick mark label individually to change its size. Other than that, super program.

27 Aug 2014 Degang

Degang (view profile)

Suggestions for improvements:
1) add an option to toggle whether to plot the grid lines or not.
2) terncontour allows passing additional comments to contour function

29 Jun 2014 Manuel Diaz  
04 May 2014 Qibiao Yu  
28 Apr 2014 Ni

Ni (view profile)

16 Jan 2014 Hee Jung Kang


16 Jan 2014 Hee Jung Kang  
27 Dec 2013 paolo

paolo (view profile)

02 Sep 2013 Yuri K

Yuri K (view profile)

Another suggestion. The vertex labels should be at 100%, not 0%.

Comment only
02 Sep 2013 Yuri K

Yuri K (view profile)

Great function! -1 because labeling with gname cannot be used due to data sorting. Make the sort optional and/or return the sorting index.

12 Aug 2013 Ricardo

Hi, this is really useful. :)) Anyhow, just to tell you that you can make this work on Octave (not very well, but decent enough to get things done), if in ternaxes.m you change
-cax = newplot;
+cax = gca();

Comment only
09 Aug 2013 Zhang Johann

It's really useful!

03 Dec 2012 Stephan Münzberg

Many Thanks for this great tool! Only one question:
I want to have only a small part of the phase diagram because the solubilities in my experiments are small. How can I do this?

23 May 2012 Scott Rowe

I agree with Marco, it would be useful if the program supported a 3d axis with scaling.

14 May 2012 Marco

Marco (view profile)

14 May 2012 Marco

Marco (view profile)

14 May 2012 Marco

Marco (view profile)

Hello, i need help with your ternplot routine. First of all, great tool for us chem. eng. students! Good work!
I want to know if its posible to add a label in the vertical axis in the 3d portion of the diagram. I need to add a temperature scale in the vertical axis.
Regards and thanks for your time!

Marco Scetta.

Comment only
14 Mar 2012 Stefan

Stefan (view profile)

The perfect ternary plot tool...simple to use and easy to adapt to specific demands :) Thanks Carl!!!

30 Jun 2011 Dominique

Thanks a lot, it works really well. I would like to plot tie-lines as well. Do you have any idea how I can do that?

14 Jun 2011 Julia

Julia (view profile)

I need to make Piper trilinear diagrams using matlab. The ternary phase diagram is great, but it is only part of the Piper trilinear diagram (used to plot hydrogeochemical facies). Does anyone know how to create a Piper trilinear diagram in matlab?

Comment only
03 Jun 2011 Anthony Pollington

I'm pretty sure that vertexlabel.m is not working quite correctly. If the data input using ternplot is
% b
% / \
% / \
% c --- a

% this function plots
% c
% / \
% / \
% a --- b

% and the vertex labelling needs to be input as vertexlabel(C,A,B)

Comment only
18 May 2011 Leonid

Leonid (view profile)

10 May 2011 Julia

Julia (view profile)

When I used ternplot some of my points are off the grid (outside the triangle) and I haven't been able to figure out the cause. Has this happened to anyone else? Can anyone help me fix the problem?


Comment only
27 Apr 2011 hamid mehdizadeh  
31 Jul 2008 Catherine Klapperich  
21 Oct 2007 Giuseppe Cardillo

Your work is excellent. Anyway there is a bug in ternplot.
Change line 33 in
function hpol = ternplot(A, B, C, varargin)
or, in alternative, change line 55 in
handles = q;

08 Aug 2007 parvez alam  
11 Nov 2006 Wolfgang Mozart

I've been trying to use your solution for my data in excel file. I exported my data into matlab, but I got two errors:
??? Input argument "A" is undefined.

Error in ==> ternplot at 40
C = 1 - (A+B);

??? Input argument "A" is undefined.

Error in ==> ternlabel at 18
r(1) = text(0.35*sin(deg2rad(30)), 0.5, A, 'rotation', 60, 'horizontalalignment', 'center');
How can I solve this problem?

Comment only
11 Nov 2006 Wolfgang Mozart

Excellent work! Have you an Idea to get 3D ternary phase plot?

03 May 2006 Marcela edith  
25 Jan 2006 soroush taghinejad  
09 Jan 2006 Karel Verscheure

Excellent work! Maybe someone can extend this to make advanced contourplots (liquidus surfaces in color etc.)?

10 Feb 2005 Yash Mahendra

Thank you so much!! It's a boon for chem engg students!

28 Dec 2004 John Dow

It's really cool!
it would be nice to have an option to draw more than one graph on the same figure. (hold on, hold off)

11 Nov 2004 roxxot jang


23 Oct 2004 B N

thanks a lot

02 Oct 2004 Priam Pillai

Excellent program. I used it for my lab reports works great.

28 Nov 2003 joe salisbury


14 Nov 2003 W Jirat

Very useful and amazing work.

21 Aug 2003 Aanhanger...:) NOT!!!!!!!!!

Die massa toets was nie funny nie.
Ek is nie 'n student in jou klas nie, maar ek
het gehoor....

17 Jun 2003 A. Schumann

These 2 routines do exactly what I've been looking for hours now. Thanks !

17 Aug 2015 1.1

* Migrated to a GitHub repository
* Fixed the problem with vertexlabel using inconsistent labelling to the rest of the plotting routines.

Contact us