更新:

更新:

我有一些由 matlab2tikz 生成的图,我想将其叠加。每个图都是一个单独的 .tikz 文件,我使用 \input 输入。我的代码目前是:

\pgfplotsset{
every axis/.append style={
scale only axis,   
},
/tikz/every picture/.append style={
trim axis left,
trim axis right,
    }
}

\newcolumntype{P}[1]{>{\centering\arraybackslash}p{#1}}
\begin{table}[h!]\centering  
     \begin{center}
     \begin{tabular}{P{6cm} P{6cm}}
     \toprule
      R220expt21 & R60expt\\
      \cmidrule(r){1-1}\cmidrule(l){2-2}
      \scalebox{0.4}{\input{images/expt21nrmse.tikz}}\llap{\raisebox{0.5cm}{\scalebox{0.2}                  {\input{images/expt21nrmse.tikz}}}}
      \scalebox{0.4}{\input{images/expt21fitD.tikz}}        
      &     
      \scalebox{0.4}{\input{images/expt2nrmse.tikz}}
      \scalebox{0.4}{\input{images/expt2fitD.tikz}}
      \\ \bottomrule
      \end{tabular}
      \caption{Fitted results for two samples. (top) NRMSE values for each q. (bottom) Fitted diffusion. (bottom insert) 2 Highlighted DICF and theoretical fits.}
      \label{tbl:1}
      \end{center}
\end{table}

目前此代码产生:

代码输出

如您所见,左上角图像的插图看起来不错,但我想将其水平移动。我尝试了主题“水平等同于 \raisebox?”中的解决方案,但出现有关处于水平模式的错误。

我的问题是:

  • 有没有一种方法,与我目前使用 \input 所做的一样,可以整齐地定位子图?
  • 我的方法是否不好?如果是,我该怎么办?

谢谢你的时间。

编辑2:完整MWE:

\documentclass[11pt,a4paper]{report}

\usepackage[a4paper,vmargin={30mm,30mm},hmargin={30mm,30mm}]{geometry}
\usepackage{graphicx,array,booktabs,pgfplots}
\usetikzlibrary{calc}

\newsavebox{\mybox}
%\sbox{\mybox}{\input{images/exp5nrmse.tikz}}
\sbox{\mybox}{%   Just use \input{images/exp5nrmse.tikz} instead of following
 \begin{tikzpicture}
\begin{axis}[%
width=4.52083333333333in,
height=3.565625in,
scale only axis,
xmin=1,
xmax=511,
xlabel={$q (\mu m^{-1})$},
ymin=0.5,
ymax=1,
ylabel={Normalized RMS error}
]
\addplot [color=blue,solid,line width=1.0pt,forget plot]
  table[row sep=crcr]{
10  0.49608542  \\
11  0.5509195   \\
12  0.54464869  \\
13  0.54379236  \\
14  0.60808362  \\
15  0.49726539  \\
16  0.61919337  \\
17  0.66339954  \\
18  0.72671426  \\
19  0.71607429  \\
};
\end{axis}
\end{tikzpicture}%
}

\pgfplotsset{
every axis/.append style={
scale only axis,   
},
/tikz/every picture/.append style={
trim axis left,
trim axis right,
    }
}

\begin{document}

\newcolumntype{P}[1]{>{\centering\arraybackslash}p{#1}}
\begin{table}[htb!]
 \centering
     \begin{tabular}{P{5.5cm} P{5.5cm}}
     \toprule
      R220expt21 & R60expt\\
      \cmidrule(r){1-1}\cmidrule(l){2-2}
      \tikz[remember picture,baseline=(a.base)]\node[scale=0.4,outer sep=0pt]
               (a){\usebox{\mybox}};
       %%% Change dimensions in $(a.east)+(-0.9,0cm)$
      \tikz[remember picture,overlay]\node[anchor=east,outer sep=0pt,scale=0.2] at
               ($(a.east)+(-0.9,0cm)$){\usebox{\mybox}};
      \scalebox{0.4}{\usebox{\mybox}}
      &
      \scalebox{0.4}{\usebox{\mybox}}
      \scalebox{0.4}{\usebox{\mybox}}
      \\ \bottomrule
      \end{tabular}
      \caption{Fitted results for two samples. (top) NRMSE values for each q. (bottom) Fitted diffusion. (bottom insert) 2 Highlighted DICF and theoretical fits.}
      \label{tbl:1}
\end{table}

\end{document}

答案1

希望这也能起作用\input

您可以使用来node放置您的.tikz文件

\documentclass{article}
\usepackage{graphicx,array,booktabs,tikz}
\usetikzlibrary{calc}
\begin{document}

\newcolumntype{P}[1]{>{\centering\arraybackslash}p{#1}}
\begin{table}[htb!]
 \centering
     \begin{tabular}{P{5.5cm} P{5.5cm}}
     \toprule
      R220expt21 & R60expt\\
      \cmidrule(r){1-1}\cmidrule(l){2-2}
      \tikz[remember picture,baseline=(a.base)]\node[scale=0.4,outer sep=0pt]
               (a){\includegraphics[width=6cm]{example-image-a}};
       %%% Change dimensions in $(a.east)+(-0.5,0cm)$ 
      \tikz[remember picture,overlay]\node[anchor=east,outer sep=0pt,scale=0.2] at
               ($(a.east)+(-0.5,0cm)$){\includegraphics[width=6cm]{example-image-b}};
      \scalebox{0.4}{\includegraphics[width=6cm]{example-image-c}}
      &
      \scalebox{0.4}{\includegraphics[width=6cm]{example-image-a}}
      \scalebox{0.4}{\includegraphics[width=6cm]{example-image}}
      \\ \bottomrule
      \end{tabular}
      \caption{Fitted results for two samples. (top) NRMSE values for each q. (bottom) Fitted diffusion. (bottom insert) 2 Highlighted DICF and theoretical fits.}
      \label{tbl:1}
\end{table}

\end{document}

在此处输入图片描述

更新:

\documentclass{article}
\usepackage{graphicx,array,booktabs,pgfplots}
\pgfplotsset{compat=1.9}
\usetikzlibrary{calc}

%% use as many boxes as you need for each plot.
\newsavebox{\mybox}
%\sbox{\mybox}{\input{images/exp5nrmse.tikz}}
\sbox{\mybox}{%   Just use \input{images/exp5nrmse.tikz} instead of following
 \begin{tikzpicture}
\begin{axis}[%
width=4.52083333333333in,
height=3.565625in,
scale only axis,
xmin=1,
xmax=511,
trim axis left,
trim axis right,
xlabel={$q (\mu m^{-1})$},
ymin=0.5,
ymax=1,
ylabel={Normalized RMS error}
]
\addplot [color=blue,solid,line width=1.0pt,forget plot]
  table[row sep=crcr]{
10  0.49608542  \\
11  0.5509195   \\
12  0.54464869  \\
13  0.54379236  \\
14  0.60808362  \\
15  0.49726539  \\
16  0.61919337  \\
17  0.66339954  \\
18  0.72671426  \\
19  0.71607429  \\
};
\end{axis}
\end{tikzpicture}%
}%
\begin{document}

\newcolumntype{P}[1]{>{\centering\arraybackslash}p{#1}}
\begin{table}[htb!]
 \centering
     \begin{tabular}{P{5.5cm} P{5.5cm}}
     \toprule
      R220expt21 & R60expt\\
      \cmidrule(r){1-1}\cmidrule(l){2-2}
      \begin{tikzpicture}[baseline=(a.base)]
      \node[scale=0.4,outer sep=0pt]  (a){\usebox{\mybox}};
       %%% Change dimensions in $(a.east)+(-0.9,0cm)$
      \node[anchor=east,outer sep=0pt,scale=0.2] at
               ($(a.east)+(-0.9,0cm)$){\usebox{\mybox}};
      \end{tikzpicture}
      \scalebox{0.4}{\usebox{\mybox}}
      &
      \scalebox{0.4}{\usebox{\mybox}}
      \scalebox{0.4}{\usebox{\mybox}}
      \\ \bottomrule
      \end{tabular}
      \caption{Fitted results for two samples. (top) NRMSE values for each q. (bottom) Fitted diffusion. (bottom insert) 2 Highlighted DICF and theoretical fits.}
      \label{tbl:1}
\end{table}

\end{document}

在此处输入图片描述

相关内容