Zie*_*ezi 2 plot legend octave figure axis-labels
我正在尝试添加一个图例,并在绘图上绘制函数,例如:
description = legend({"y(x) = \sqrt{\frac{100(1-0.10x^2)^2+0.02x^2}{(1-x^2)^2+0.1x^2}}"});
legend(description ,"location", "northoutside");
Run Code Online (Sandbox Code Playgroud)
然而,我得到的结果是:
包含 LaTeX 数学模式符号的正确语法是什么?
Windows 10 上的 Octave-4.2.1
我可以确认这在 matlab 中有效:
p = plot(1:10);
description = '$y(x) = \sqrt{\frac{100(1-0.10x^2)^2+0.02x^2}{(1-x^2)^2+0.1x^2}}$';
l = legend(description);
set(l, 'interpreter', 'latex');
Run Code Online (Sandbox Code Playgroud)
但不是八度。
所以大概安迪在链接帖子中提到的问题仍然存在。
我知道这并不理想,但作为一种解决方法,我会简单地导入一个预渲染的乳胶图像axes,然后手动将它放在主图的axes. 我发现生成乳胶文本/方程片段的最快方法是使用 anki。
例如,我用 anki 生成了这个: 
然后在八度中我可能会这样做:
PlotAxes = axes();
plot(1:10, 'g');
set (PlotAxes, 'position', [0.1, 0.1, 0.8, 0.7]);
LegendAxes = axes();
[LegendText, Colourmap] = imread('https://i.stack.imgur.com/dOOnQ.png');
LegendText = ind2rgb (LegendText, Colourmap);
imagesc(LegendText);
axis equal tight;
Lims = axis;
hold on;
LegendLine = plot ([-150, -50], [50, 50], 'linewidth', 3, 'g');
hold off;
axis(Lims + [-200, 0, 0, 0]);
set (LegendAxes, ...
'position', [0.2, 0.85, 0.6, 0.1], ...
'xtick', [], 'ytick', [], 'box', 'on');
Run Code Online (Sandbox Code Playgroud)
结果:

这种手动放置一开始可能看起来很麻烦,但是一旦你习惯了,我保证你会真正喜欢它。我论文中的所有图形都是“手动”定位的(尽管通常以自动方式),因为这让我可以完全控制。