在多行中对齐 tikzpicture

在多行中对齐 tikzpicture

希望我没有忽略这个问题。我正尝试将多行中的 tikzpicture 与不同列中的其他两张 tikzpicture 对齐。

在此处输入图片描述

这是代码:

\documentclass{article} 
\usepackage[english]{babel} 
\usepackage{tabularx,multirow,tikz,pgfplots}
\pgfplotsset{compat=1.10}
\begin{document}
\selectlanguage{english}
\Large Figure 1
\smallskip
\resizebox{10cm}{!}{
\begin{tabular}[t]{ll}
{\Huge (a)}& {\Huge (b)}\\
\multirow{2}{*}{%
\begin{tikzpicture}[scale=2]
 \begin{axis}[scatter/use mapped color=  {draw=black,fill=white},
    xtick={-90,0,90}, ytick={-40,0,40},
   ylabel=A,xlabel=B,font=\footnotesize,xmin=-99,xmax=99,ymin=-50,ymax=50,height=6cm]
\addplot[scatter] 
table [x=A,y=B,only marks,row sep=crcr] 
    {A B
-90 -30\\
0 0 \\
90 30\\
};
  \end{axis}
\end{tikzpicture}}&
    \begin{tikzpicture}[scale=2]
    \begin{axis}[font=\footnotesize,ytick={0,1,2,3,4},
x=1.2cm,title=bla,footnotesize,xmin=-0.5, xmax=3.5,xtick=\empty,ymin=0,
    ylabel style = {text width=3cm}, ylabel=C]
\addplot[ybar,error bars/.cd,  y dir=both,y explicit] plot coordinates    {    (0,3) +- (0,0.5)};
  \addplot[ybar,error bars/.cd,  y dir=both,y explicit] plot coordinates{(1,3) +- (0,0.5)};
  \addplot[ybar,error bars/.cd,  y dir=both,y explicit] plot coordinates{(2,3) +- (0,0.5)};
  \addplot[ybar,error bars/.cd,  y dir=both,y explicit] plot coordinates{(3,3) +- (0,0.5)   };
\end{axis}\end{tikzpicture}\\
&\begin{tikzpicture}[scale=2]
\begin{axis}[x=1.2cm,
title=bla bla,
ylabel style = {text width=3cm},footnotesize,xmin=-0.5,xmax=3.5,xtick={0,1,2,3},xticklabels={one,two,three,four},ytick={0,1,2,3},ymin=0,ylabel =D]
 \addplot[ ybar,error bars/.cd,  y dir=both,y explicit] plot coordinates    {    (0,2) +- (0,1)};
    \addplot[,ybar,error bars/.cd,  y dir=both,y explicit] plot coordinates{(1,2) +- (0,1)};
    \addplot[ ybar,error bars/.cd,  y dir=both,y explicit] plot coordinates{(2,2) +- (0,1)};
    \addplot[ybar,error bars/.cd,  y dir=both,y explicit] plot coordinates{(3,2 ) +- (0,1)  };
\end{axis}
\end{tikzpicture}  \\
\end{tabular}
}\end{document}

我试过玩

baseline=(current bounding box.north)

但似乎没有效果。我也尝试过修复左侧 tikzpicture 的大小,但这并不能解决对齐问题。

答案1

我会将列类型更改cm,不要缩放整个表格并且不使用multirow单元格。

关于图表,我将图表宽度定义为等于单元格宽度,然后删除scale。对于第一列的图片,我将在图表的垂直中间定义基线:

\documentclass{article}
\usepackage[english]{babel}
\usepackage{multirow, tabularx} 
\usepackage{pgfplots}           % it load "tikz"
\pgfplotsset{compat=1.10}       % recent version is 1.16, upgrade it!

%---------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%

\begin{document}
\Large Figure 1
\smallskip

\noindent\begin{tabular}{*{2}{m{\dimexpr0.5\linewidth-2\tabcolsep}} }
{\Huge (a)} & {\Huge (b)}   \\
\begin{tikzpicture}[baseline=(current bounding box.base)]
    \begin{axis}[
    width=\linewidth,
    scatter/use mapped color={draw=black,fill=white},
    xtick={-90,0,90}, ytick={-40,0,40},
    ylabel=A,xlabel=B,
    font=\footnotesize,
    xmin=-99,xmax=99,ymin=-50,ymax=50]
\addplot[scatter]
table [x=A,y=B,only marks,row sep=crcr]
    {A B
-90 -30\\
0 0 \\
90 30\\
};
  \end{axis}
\end{tikzpicture}
    &   \begin{tikzpicture}
    \begin{axis}[
    width=\linewidth,
    font=\footnotesize,
    ytick={0,1,2,3,4},
    x=1.1cm,
    title=bla,footnotesize,
    xmin=-0.5, xmax=3.5,
    xtick=\empty,ymin=0,
    ylabel style = {text width=3cm},
    ylabel=C]
  \addplot[ybar,error bars/.cd,  y dir=both,y explicit] plot coordinates { (0,3) +- (0,0.5)};
  \addplot[ybar,error bars/.cd,  y dir=both,y explicit] plot coordinates { (1,3) +- (0,0.5)};
  \addplot[ybar,error bars/.cd,  y dir=both,y explicit] plot coordinates { (2,3) +- (0,0.5)};
  \addplot[ybar,error bars/.cd,  y dir=both,y explicit] plot coordinates { (3,3) +- (0,0.5)};
\end{axis}
    \end{tikzpicture}

    \begin{tikzpicture}
    \begin{axis}[
    width=\linewidth,
    font=\footnotesize,
    ytick={0,1,2,3,4},
    x=1.1cm,
    title=bla,footnotesize,
    xmin=-0.5, xmax=3.5,
    xtick=\empty,ymin=0,
    ylabel style = {text width=3cm},
    ylabel=D]
 \addplot[ ybar,error bars/.cd,  y dir=both,y explicit] plot coordinates    {    (0,2) +- (0,1)};
    \addplot[ybar,error bars/.cd,  y dir=both,y explicit] plot coordinates{(1,2) +- (0,1)};
    \addplot[ybar,error bars/.cd,  y dir=both,y explicit] plot coordinates{(2,2) +- (0,1)};
    \addplot[ybar,error bars/.cd,  y dir=both,y explicit] plot coordinates{(3,2 ) +- (0,1)  };
\end{axis}
\end{tikzpicture}
\end{tabular}
\end{document}

在此处输入图片描述

(红线表示文本区域边框)

相关内容