我尝试将图形垂直放置到同一个图形中。但是,我无法使用tabular
withtikzpicture
来执行此操作。
\begin{figure}[]
\begin{center}
\begin{tikzpicture}[scale=0.9]
\begin{axis}[
width=\linewidth, % Scale the plot to \linewidth
height=0.5\linewidth,
grid style={dashed,gray!60},
ylabel=Performance gain/drop percentage,
yticklabel={\pgfmathprintnumber\tick\%},
legend style={at={(1,0)},anchor=south east},
xticklabels={,,},
xlabel=Something
]
\addplot[smooth,color=orange,mark=x,thick]
table[x=index,y=data,col sep=semicolon] {C2.csv};
\addplot[smooth,color=blue,mark=*,thick]
table[x=index,y=data,col sep=semicolon] {C2.csv};
\legend{Something}
\end{axis}
\end{tikzpicture}
\caption{Something}
\label{figure_2_s}
\end{center}
\end{figure}
\begin{figure}[]
\begin{center}
\begin{tikzpicture}[scale=0.9]
\begin{axis}[
width=\linewidth, % Scale the plot to \linewidth
height=0.5\linewidth,
grid style={dashed,gray!60},
ylabel=Performance gain/drop percentage,
yticklabel={\pgfmathprintnumber\tick\%},
legend style={at={(1,0)},anchor=south east},
xticklabels={,,},
xlabel=Something
]
\addplot[smooth,color=orange,mark=x,thick]
table[x=index,y=data,col sep=semicolon] {C4.csv};
\addplot[smooth,color=blue,mark=*,thick]
table[x=index,y=data,col sep=semicolon] {C4.csv};
\addplot[smooth,color=gray,mark=o,thick]
table[x=index,y=data,col sep=semicolon] {C4.csv};
\legend{Something}
\end{axis}
\end{tikzpicture}
\caption{Something}
\label{figure_4_s}
\end{center}
\end{figure}
答案1
我不确定你的问题,但我知道你想要两个tikzpictures
在里面figure
,可能每个都有标签和标题。你可以使用subcaption
包。由于你希望你的图形垂直对齐,所以不需要minipage
或环境,但如果你想与主图形区分开来,subfigure
你必须将每个图形包含在自己的范围内。{...}
subcations
caption
\documentclass{article}
\usepackage{pgfplots}
\usepackage{subcaption}
\begin{document}
\begin{figure}[]
\centering
{%First subfigure
\begin{tikzpicture}[scale=0.9]
\begin{axis}[
width=\linewidth, % Scale the plot to \linewidth
height=0.5\linewidth,
grid style={dashed,gray!60},
ylabel=Performance gain/drop percentage,
yticklabel={\pgfmathprintnumber\tick\%},
legend style={at={(1,0)},anchor=south east},
xticklabels={,,},
xlabel=Something
]
% \addplot[smooth,color=orange,mark=x,thick]
% table[x=index,y=data,col sep=semicolon] {C2.csv};
% \addplot[smooth,color=blue,mark=*,thick]
% table[x=index,y=data,col sep=semicolon] {C2.csv};
\legend{Something}
\end{axis}
\end{tikzpicture}
\subcaption{First subfigure}
\label{figure_2_s}
}
{%Second subfigure
\begin{tikzpicture}[scale=0.9]
\begin{axis}[
width=\linewidth, % Scale the plot to \linewidth
height=0.5\linewidth,
grid style={dashed,gray!60},
ylabel=Performance gain/drop percentage,
yticklabel={\pgfmathprintnumber\tick\%},
legend style={at={(1,0)},anchor=south east},
xticklabels={,,},
xlabel=Something
]
\legend{Something}
\end{axis}
\end{tikzpicture}
\subcaption{Second subfigure}
\label{figure_4_s}
}
\caption{A figure with two subfigures}
\end{figure}
\end{document}
答案2
您不需要两个figure
环境。您也不需要tabular
。将两个tikzpicture
s 放在同一个figure
环境中,并在它们之间留出一个空白行,以使它们垂直对齐。
\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.12}
\begin{document}
\begin{figure}[htb]
\centering
\begin{tikzpicture}[scale=0.9]
\begin{axis}[
width=\linewidth, % Scale the plot to \linewidth
height=0.5\linewidth,
grid style={dashed,gray!60},
ylabel=Performance gain/drop percentage,
yticklabel={\pgfmathprintnumber\tick\%},
legend style={at={(1,0)},anchor=south east},
xticklabels={,,},
xlabel=Something
]
\addplot[smooth,color=orange,mark=x,thick]
{rnd};
\addplot[smooth,color=blue,mark=*,thick]
{rnd};
\legend{Something}
\end{axis}
\end{tikzpicture}
\caption{Something}
\label{figure_2_s}
\begin{tikzpicture}[scale=0.9]
\begin{axis}[
width=\linewidth, % Scale the plot to \linewidth
height=0.5\linewidth,
grid style={dashed,gray!60},
ylabel=Performance gain/drop percentage,
yticklabel={\pgfmathprintnumber\tick\%},
legend style={at={(1,0)},anchor=south east},
xticklabels={,,},
xlabel=Something
]
\addplot[smooth,color=orange,mark=x,thick]
{rnd};
\addplot[smooth,color=blue,mark=*,thick]
{rnd};
\addplot[smooth,color=gray,mark=o,thick]
{rnd};
\legend{Something}
\end{axis}
\end{tikzpicture}
\caption{Something}
\label{figure_4_s}
\end{figure}
\end{document}