尝试使用.tikz
从 MATLAB 脚本生成的文件时,该.tex
文件出现错误并且无法构建。
代码.tex
如下:
\documentclass{article}
\usepackage{amsmath}
\numberwithin{figure}{section}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\newlength\figureheight
\newlength\figurewidth
\begin{document}
\begin{figure}[h]
\setlength\figureheight{2cm}
\setlength\figurewidth{0.84\textwidth}
\input{IntroGraph.tikz}
\end{figure}
\end{document}
IntroGraph.tikz 如下所示:
\definecolor{mycolor1}{rgb}{0.00000,0.44700,0.74100}
\begin{tikzpicture}
\begin{axis}[%
width=0.951\figurewidth,
height=\figureheight,
at={(0\figurewidth,0\figureheight)},
scale only axis,
xmin=0.5,
xmax=5.5,
xtick={1,2,3,4,5},
xticklabels={{\phi^1},{\phi^2},{\phi^3 = \phi^{Opt}},{\phi^4},{\phi^5}},
xlabel={Investment Options},
xmajorgrids,
ymin=1,
ymax=8,
ytick={1,2,3,4,5,6,7,8},
yticklabels={{0},{},{\mu^T\phi^5},{\mu^T\phi^4},{\mu^T\phi^1},{\mu^T\phi^2},{\mu^T\phi^3},{}},
ylabel={Portfolio Expected Return},
ymajorgrids,
axis background/.style={fill=white},
title style={font=\bfseries},
title={Returns of Investement Options}
]
\addplot [color=mycolor1,only marks,mark=x,mark options={solid},forget plot]
plot [error bars/.cd, y dir = both, y explicit]
table[row sep=crcr, y error plus index=2, y error minus index=3]{%
1 5 1.7 3.7\\
2 6 1.5 1.5\\
3 7 0.3 0.5\\
4 4 2.3 1.2\\
5 3 4.9 0.7\\
};
\end{axis}
\end{tikzpicture}%