在表格上堆叠条形图

在表格上堆叠条形图

我想把条形图超过 表格。我无法做到这一点,也不明白为什么。

\documentclass[border=10pt]{standalone}
\usepackage{verbatim}
\usepackage{pgfplot}
\pgfplotsset{width=7cm,compat=1.8}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
    x tick label style={
        /pgf/number format/1000 sep=},
    ylabel=Year,
    enlargelimits=0.05,
    legend style={at={(0.5,-0.1)},
    anchor=north,legend columns=-1},
    ybar interval=0.7,
]
\addplot 
    coordinates {(2012,408184) (2011,408348)
         (2010,414870) (2009,412156) (2008,415 838)};
\addplot 
    coordinates {(2012,388950) (2011,393007) 
        (2010,398449) (2009,395972) (2008,398866)};
\legend{Men,Women}
\end{axis}
\end{tikzpicture}
\begin{tabular}{c|c|c|c}
{\sc Dossiers} & {\sc Pages} & {\sc \'Echéances} & {\sc Label}\\
\hline
\hline
Histoire des Sciences (1) & 15p mini & 01/01/17 & A\\
\hline
Histoire des Sciences (2) & 15p mini & 01/01/17 & B\\
\hline
Neurosciences & 10 (2x5) & 01/01/17 & C\\
\hline
Histoire         & 6-10p    & 01/01/17 & D\\
\hline
Histoire des SVT & 10p      & " + 2 sem. & E 
\end{tabular}
\end{document}

答案1

tikzpicture并且tabular没有特殊的间距规则,它们只是像大字母一样定位。

你有

X
Y

这使得

XY

你想要

X

Y

这使得

X

如果使用standalone类你需要

\documentclass[border=10pt,varwidth]{standalone}

varwidth对于任何垂直模式构造。

答案2

另外,您还可以将 放在tabular内部\nodetikzpicture此外,请注意 已\sc被弃用,取而代之的是\scshape,请参阅\textit我使用或\it\bfseries等有关系吗\bf

\documentclass[border=10pt]{standalone}
\usepackage{booktabs} % added for \toprule,\midrule,\bottomrule
\usepackage{array} % added for the *{4}{c} syntax
\usepackage{pgfplots}
\pgfplotsset{width=7cm,compat=1.8}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
    x tick label style={
        /pgf/number format/1000 sep=},
    ylabel=Year,
    enlargelimits=0.05,
    legend style={at={(0.5,-0.1)},
    anchor=north,legend columns=-1},
    ybar interval=0.7,
]
\addplot 
    coordinates {(2012,408184) (2011,408348)
         (2010,414870) (2009,412156) (2008,415 838)};
\addplot 
    coordinates {(2012,388950) (2011,393007) 
        (2010,398449) (2009,395972) (2008,398866)};
\legend{Men,Women}
\end{axis}
\node [above] at (current bounding box.north) {%
\begin{tabular}{*{4}{c}}
\toprule
\scshape Dossiers & \scshape Pages & \scshape \'Echéances & \scshape Label\\
\midrule
Histoire des Sciences (1) & 15p mini & 01/01/17 & A\\
Histoire des Sciences (2) & 15p mini & 01/01/17 & B\\
Neurosciences & 10 (2x5) & 01/01/17 & C\\
Histoire         & 6--10p    & 01/01/17 & D\\
Histoire des SVT & 10p      & " + 2 sem. & E  \\
\bottomrule
\end{tabular}
};
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容