是否有可能在 matlab2tikz 脚本生成的 tikzpicture 中的每个轴上添加一个字母/数字(没有额外的文本),也许带有\subcaption
?由于空间不足,如果解决方案不像本草稿中那样放大图形并且字母与 y 轴标签和 x 轴的数字对齐,那就太好了:
这些“子图”是为了在文本中快速引用而需要的。也欢迎其他想法。
(几乎)MWE:
\documentclass{standalone}
\usepackage[labelformat=simple]{subcaption}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\usepackage{tikz}
\usetikzlibrary{shadows}
\newlength\figureheight
\newlength\figurewidth
\begin{document}
\minipage{\textwidth}
\begin{figure}
\setlength\figureheight{10cm}
\setlength\figurewidth{0.9\textwidth}
% This file was created by matlab2tikz.
% Minimal pgfplots version: 1.3
%
%The latest updates can be retrieved from
% http://www.mathworks.com/matlabcentral/fileexchange/22022-matlab2tikz
%where you can also make suggestions and rate matlab2tikz.
%
\definecolor{mycolor1}{rgb}{0.00000,0.44700,0.74100}%
\definecolor{mycolor2}{rgb}{0.85000,0.32500,0.09800}%
\definecolor{mycolor3}{rgb}{0.92900,0.69400,0.12500}%
\definecolor{mycolor4}{rgb}{0.49400,0.18400,0.55600}%
\definecolor{mycolor5}{rgb}{0.46600,0.67400,0.18800}%
%
\begin{tikzpicture}
\begin{axis}[%
width=0.95092\figurewidth,
height=0.125874\figureheight,
at={(0\figurewidth,0.699301\figureheight)},
scale only axis,
xmin=0,
xmax=8,
ymin=-5,
ymax=35,
ylabel={$\phi_{TC}\,[^\circ]$},
ylabel absolute, every axis/.append style={thick}, axis lines = left, tick align=center, grid=both , legend style={rounded corners=3pt, append after command={\pgfextra{\draw[rounded corners=3pt, drop shadow={fill=black, opacity=0.5, shadow xshift=2pt, shadow yshift=-2pt}](\tikzlastnode.south west)rectangle(\tikzlastnode.north east);}}}
]
\addplot [color=mycolor1,solid,forget plot]
table[row sep=crcr]{%
0 0\\
8 -0.0315641317884584\\
};
\end{axis}
\begin{axis}[%
width=0.95092\figurewidth,
height=0.125874\figureheight,
at={(0\figurewidth,0.174825\figureheight)},
scale only axis,
xmin=0,
xmax=8,
ymin=-40,
ymax=5,
minor y tick num=1,
ylabel={$\theta\,[^\circ]$},
ylabel absolute, every axis/.append style={thick}, axis lines = left, tick align=center, grid=both , legend style={rounded corners=3pt, append after command={\pgfextra{\draw[rounded corners=3pt, drop shadow={fill=black, opacity=0.5, shadow xshift=2pt, shadow yshift=-2pt}](\tikzlastnode.south west)rectangle(\tikzlastnode.north east);}}}
]
\addplot [color=mycolor1,solid,forget plot]
table[row sep=crcr]{%
0 0\\
8 0.0318107670813533\\
};
\addplot [color=mycolor2,dashed,forget plot]
table[row sep=crcr]{%
0 0\\
8 0.0323545985468902\\
};
\end{axis}
\begin{axis}[%
width=0.95092\figurewidth,
height=0.125874\figureheight,
at={(0\figurewidth,0\figureheight)},
scale only axis,
xmin=0,
xmax=8,
xlabel={Time $[\textrm{s}]$},
ymin=-20,
ymax=15,
ylabel={$\psi\,[^\circ]$},
ylabel absolute, every axis/.append style={thick}, axis lines = left, tick align=center, grid=both , legend style={rounded corners=3pt, append after command={\pgfextra{\draw[rounded corners=3pt, drop shadow={fill=black, opacity=0.5, shadow xshift=2pt, shadow yshift=-2pt}](\tikzlastnode.south west)rectangle(\tikzlastnode.north east);}}}
]
\addplot [color=mycolor1,solid,forget plot]
table[row sep=crcr]{%
0 0\\
8 -0.0140806721559224\\
};
\addplot [color=mycolor2,dashed,forget plot]
table[row sep=crcr]{%
0 0\\
8 -0.0198948008416377\\
};
\end{axis}
\begin{axis}[%
width=0.95092\figurewidth,
height=0.125874\figureheight,
at={(0\figurewidth,0.34965\figureheight)},
scale only axis,
xmin=0,
xmax=8,
ymin=-10,
ymax=60,
ylabel={$\phi\,[^\circ]$},
ylabel absolute, every axis/.append style={thick}, axis lines = left, tick align=center, grid=both , legend style={rounded corners=3pt, append after command={\pgfextra{\draw[rounded corners=3pt, drop shadow={fill=black, opacity=0.5, shadow xshift=2pt, shadow yshift=-2pt}](\tikzlastnode.south west)rectangle(\tikzlastnode.north east);}}}
]
\addplot [color=mycolor1,solid,forget plot]
table[row sep=crcr]{%
0 0\\
8 -0.0648771465141066\\
};
\addplot [color=mycolor2,dashed,forget plot]
table[row sep=crcr]{%
0 0\\
8 -0.0676623487911467\\
};
\end{axis}
\begin{axis}[%
width=0.95092\figurewidth,
height=0.125874\figureheight,
at={(0\figurewidth,0.524475\figureheight)},
scale only axis,
xmin=0,
xmax=8,
ymin=-40,
ymax=5,
minor y tick num=1,
%minor x tick num=9,
ylabel={$\theta_{TC}\,[^\circ]$},
ylabel absolute, every axis/.append style={thick}, axis lines = left, tick align=center, grid=both , legend style={rounded corners=3pt, append after command={\pgfextra{\draw[rounded corners=3pt, drop shadow={fill=black, opacity=0.5, shadow xshift=2pt, shadow yshift=-2pt}](\tikzlastnode.south west)rectangle(\tikzlastnode.north east);}}}
]
\addplot [color=mycolor1,solid, thick,forget plot]
table[row sep=crcr]{%
0 -0\\
8 0.0316344682291074\\
};\label{Plot_TC_Simple}
\addplot [color=mycolor2,dashed, thick,forget plot]
table[row sep=crcr]{%
0 -0\\
8 0.0315641365781371\\
};\label{Plot_TC_Normal}
\end{axis}
\begin{axis}[%
width=0.95092\figurewidth,
height=0.125874\figureheight,
at={(0\figurewidth,0.874126\figureheight)},
scale only axis,
xmin=0,
xmax=8,
ymin=-0.2,
ymax=4.2,
legend style={font=\footnotesize, legend cell align=left,align=left,draw=black, legend columns=2, at = {(axis cs:0.5,4.7)}, anchor=south west},
ylabel absolute, every axis/.append style={thick}, axis lines = left, tick align=center, grid=both , legend style={rounded corners=3pt, append after command={\pgfextra{\draw[rounded corners=3pt, drop shadow={fill=black, opacity=0.5, shadow xshift=2pt, shadow yshift=-2pt}](\tikzlastnode.south west)rectangle(\tikzlastnode.north east);}}}
]
\addplot [color=mycolor4,solid]
table[row sep=crcr]{%
0 4\\
6 4\\
6 0\\
8 0\\
};
\addlegendentry{$a_{x}^L=a_{y}^L\,\left[\mathrm{m}\,\mathrm{s}^{-2}\right]$};
\addplot [color=mycolor3,dashed]
table[row sep=crcr]{%
0 0\\
3 0\\
3 4\\
5 4\\
5 0\\
8 0\\
};
\addlegendentry{$\dot{\phi}^L\,\left[\mathrm{rad}\,\mathrm{s}^{-1}\right]$};
\end{axis}
\end{tikzpicture}%
\caption{Comparison} % caption
\end{figure}
\endminipage
\end{document}
答案1
这是使用手动对齐进行操作的方法。
\documentclass[border=.1in]{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[ylabel=y,
extra description/.code={\node[below left,inner sep=0pt] at (-1cm,0) {a)};}]
\addplot coordinates {(0,0) (5,5)};
\end{axis}
\end{tikzpicture}
\end{document}