Plotting Ternary Phase Diagram with MATLAB

6.2k views Asked by At

I would like to plot a ternary phase diagram based on ab-initio energy inputs. There, I found a useful tool which may help me:

https://de.mathworks.com/matlabcentral/fileexchange/2299-alchemyst-ternplot

There are several issues I need to alter:

  1. I like to see my input phase "name labels" on the plot, where I entered the coordinates in data. (Not just blue dots in separate figure)

  2. I have entered positive energy values in terndemo.m, as shown in below. Nevertheless, they are actually negative values and when I entered negative values surface does not shown properly.

  3. I need to give a label for the heat spectrum ?

  4. Lastly, my axis labels are not starting correct. For instance 0 is not at the edge point in the triangle.

I also attached all questions on the figure.

Can anybody give some comments on that questions ?

--- Here is my demotern.m input:

%% Ti Ce Fe
% Name of the phases in coordinates below: Ti, Ce, Fe, FeTi, Fe2Ti,
% CeFe2,CeFe5, Ce2Fe17 and CeFe11Ti
experimental = [...

    1.000   0.000   0.000
    0.000   1.000   0.000
    0.000   0.000   1.000
    0.500   0.000   0.500
    0.340   0.000   0.660
    0.000   0.340   0.660
    0.000   0.160   0.840
    0.000   0.110   0.890
    0.0765  0.0765  0.847
   ];
% data values are actually negative, here I enter positive value
data = [...

    0.0
    0.0
    0.0
    0.419
    0.273
    0.090
    0.014
    0.010
    0.068
    ];

A = experimental(:, 1)';
B = experimental(:, 2)';
C = 1 - (A + B);

figure
subplot(2, 2, 1)
ternplot(A, B, C, '.'); ternlabel('Content of Titanium', 'Content of Cerium', 'Content of Iron');
subplot(2, 2, 2)
ternpcolor(A, B, data); ternlabel('Content of Titainum', 'Content of Cerium', 'Content of Iron');
shading interp
subplot(2, 2, 3)
terncontour(A, B, data); ternlabel('Content of Titanim', 'Content of Cerium', 'Content of Iron');
subplot(2, 2, 4)
ternsurf(A, B, data);

Here is the image

1

There are 1 answers

2
chthonicdaemon On BEST ANSWER

I am the author of ternplot

Here is the best that I can do:

  1. Added labels to the plot
  2. The way in which I draw the surface plot in ternpcolor makes it hard to use negative values. There is a solution which involves viewing the figure from below, but I'll leave that for another question
  3. Added a label to the colorbar
  4. In my plots the labels are correct. Check that you have the latest version.

--

names = {'Ti', 'Ce', 'Fe', 'FeTi', 'Fe2Ti', 'CeFe2', 'CeFe5', ...
         'Ce2Fe17', 'CeFe11Ti'};
figure
ternpcolor(A, B, data); 
vertexlabel('Titainum', 'Cerium', 'Iron');
shading interp
c = colorbar();
ylabel(c, 'Formation energy per atom (eV)')
hold on
for i = 1:length(names)
    [x, y] = terncoords(experimental(i, 1), experimental(i, 2));
    z = data(i);

    scatter3(x, y, z+0.4, 100, 'filled', 'ks');
    t = text(x + 0.01, y-0.02, z+0.03, names{i}, 'fontsize', 20);
end
hold off

It comes out as below with no hand-editing:

Output with no editing

But with a little tweaking (really just moving the labels around) it's quite usable:

Output hand-edited