matlab - 使用 MATLAB 绘制三元相图

标签 matlab plot ternary ternplot

我想绘制一个基于从头算能量输入的三元相图。在那里,我找到了一个可能对我有帮助的有用工具:

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

有几个问题我需要修改:

  1. 我喜欢在绘图上看到我的输入阶段“名称标签”,我在其中输入了数据中的坐标。 (不只是单独图中的蓝点)

  2. 我在 terndemo.m 中输入了正能量值,如下所示。然而,它们实际上是负值,当我输入负值时,表面没有正确显示。

  3. 我需要给热谱贴上标签吗?

  4. 最后,我的轴标签没有开始正确。例如0不在三角形的边缘点。

我还附上了图中的所有问题。

任何人都可以对这些问题发表一些评论吗?

--- 这是我的 demotern.m 输入:

%% 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

最佳答案

我是 ternplot 的作者

这是我能做的最好的:

  1. 为绘图添加标签
  2. 我在 ternpcolor 中绘制曲面图的方式使得很难使用负值。有一个解决方案涉及从下方查看该图,但我会把它留给另一个问题
  3. 在颜色条上添加了标签
  4. 在我的图中,标签是正确的。检查您是否拥有最新版本。

--

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

未经手工编辑,结果如下:

Output with no editing

但稍微调整一下(实际上只是移动标签)它非常有用:

Output hand-edited

关于matlab - 使用 MATLAB 绘制三元相图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40489271/

相关文章:

ruby-on-rails - 如何在 Ruby on Rails 中内联编写条件三元运算符?

MATLAB根据第1列条件维护2列

matlab - 如何求解这个受约束的正值非线性方程组?

matlab - 生成1到10之间的随机数,matlab中的单个数字除外

python - 在 map Bokeh 上执行面积图时,它显示空白框并且不起作用

r - xtsExtra 中的颜色选项

r - 如何更改预测对象图中的 y 轴刻度?

file - Matlab 的 "fileattrib"函数中可能存在错误。解决方法?

python - x = (10<n) 的 Python 等价物是什么? 10 : n;