如何将MATLAB图形图例文本渲染为LaTeX?

时间:2014-03-18 21:02:33

标签: matlab legend

虽然我在MATLAB中使用LaTeX渲染了我的图例文本,如下所示

set(myLegend, 'fontsize', 8, 'interpreter','latex', 'Position', [0.67, 0.12, 0.3, 0.01]);

我仍然觉得这些文本与我的主要文本有很大的不同。例如,文本看起来很难看,因为字母相距太远。此外,罢工太薄了。

enter image description here

如何让它们看起来与下面的标题完全相同?

2 个答案:

答案 0 :(得分:0)

您可以使用Matlab2tikz实际导出Matlab数字。获得Matlab数字后,只需将其LaTeX插入\input{myfigure.tex}文件。

使用Matlab2tikz非常简单,如README文件中所述:

工作流程如下。

  1. 一个。将matlab2tikz脚本(src /文件夹的内容)放在目录中   MATLAB可以找到它(例如当前目录)。

    湾确保您的LaTeX安装包含软件包

    • TikZ(又名PGF,> = 2.00)和
    • Pgfplots(> = 1.3)。
  2. 在MATLAB中生成你的情节。

  3. Matlab matlab2tikz()调用matlab2tikz;或matlab2tikz('myfile.tex'); 该脚本接受了许多选项;通过调用帮助来检查它们,help matlab2tikz有时,MATLAB通过保持不可见的对象或将图形拉得太远超出边界框而难以创建匹配的LaTeX图。使用Matlab cleanfigure; matlab2tikz('myfile.tex');`首先清理不需要的实体图,然后将其转换为TeX。

  4. myfile.tex的内容添加到LaTeX源代码中;一个 这样做的便捷方法是使用\input{/path/to/myfile.tex}。 还要确保在文档的标题中包含Pgfplots包 包括在内

  5. 这应该在您的.tex文件中:

    \documentclass{article}
    \usepackage{pgfplots}
    % and optionally (as of Pgfplots 1.3):
    \pgfplotsset{compat=newest}
    \pgfplotsset{plot coordinates/math parser=false}
    \newlength\figureheight
    \newlength\figurewidth
    \begin{document}
    \input{myfile.tex}
    \end{document}
    

答案 1 :(得分:0)

这就是我通常在传说中嵌入乳胶的方法,

class Item puts "Enter name" def name @username = $stdin.gets.chomp loading end def loading (0..2).each do |x| puts "." end end end item = Item.new puts "Thankyou #{item.name}" #=> returns (0..2) l = legend('$\alpha$', '$\dot{\alpha}$', '$x$', '$\dot{x}$');

出于某种原因,可能是一个错误,它只适用于通过对象的setter设置解释器时。

要执行上述标题,请尝试

set(l, 'interpreter', 'latex', 'location', 'northwest', 'FontSize', 15) l = legend('(b) $t=9:00 \Delta t$

相关问题