在 pgfplot 中添加绘图之间的水平空间

在 pgfplot 中添加绘图之间的水平空间

我找不到在 pgfplots 中在两个图之间添加水平空间的任何解决方案。xshift 没用。以下是代码:

\documentclass{sigplanconf}
\usepackage{pgfplots}
\usepackage{pgfplotstable}
\usetikzlibrary{patterns}
\newcommand{\benchmark}{\textsf}
\usepgfplotslibrary{groupplots}
\usepackage{tikz}

\begin{document}

\pgfplotstableread{
1   identityOnly    both    otherOnly   average
a   0.00035173  0.00000422  0.00924541  0.12608777
b   0.00414079  0.00004965  0.10757113  0.00710518
c   0.00151162  0.00001813  0.04330784  0.13753664
d   0.00217766  0.00002526  0.06139371  0.00758067
e   0.00020642  0.00000249  0.00522527  0.00284578
f   0.00031703  0.00000380  0.02087894  0.00136650
g   0.00027212  0.00000324  0.00792774  0.00048840
h   0.10207314  0.00117326  2.63160651  0.22854330
i   0.05835732  0.00069973  1.47180476  0.34421183
j   0.00037218  0.00000434  0.01114818  0.00066935
y   0.03092297  0.00076165  1.36742588  0.09255707
}\america

\pgfplotstableread{
2   identityOnly    both    otherOnly   average
a   0.00177559  0.00003829  0.01138671  0.59759797
b   0.00234154  0.00004846  0.01488595  0.03278631
c   0.18083768  0.00392767  1.16344514  0.48364955
d   0.01192064  0.00026252  23.04508701 0.34154430
e   0.00642905  0.00013141  0.04140265  0.61546999
f   0.00331963  0.00008098  0.02224024  0.18646432
g   0.00325105  0.00006975  0.02156987  0.00076972
h   0.00220147  0.00004353  0.01544681  0.00065892
i   0.48762922  0.01007653  3.16949441  0.11817139
j   0.00368832  0.00007947  0.02380314  0.00196147
z   0.00385464  0.00212952  0.666095    0.494621
}\europe


\begin{figure}  
\centering
\begin{minipage}{0.45\columnwidth}
\centering
\begin{tikzpicture}[scale = .5, transform shape]
\begin{axis}[
 ybar stacked,
 axis x line*=bottom, 
 symbolic x coords={a,b,c,d,e,f,g,h,i,j,y},
 ymin=0, 
 xticklabel = {\benchmark{\tick}},
 yticklabel={ $\pgfmathprintnumber{\tick}\,\%$ },
 xtick=data,
 x tick label style={rotate=45,anchor=east,font=\Large},
 y tick label style={font=\Large},
 title style={font=\Large},
 xtick align=outside,
 ytick align=inside,
 every node near coord/.append style = {
   anchor = west, yshift = -2pt,
   rotate = 90,
   font = {\Large},
   /pgf/number format/fixed,
 }, title={1},
 cycle list = {
   { fill = gray },
   { fill = darkgray },
   { fill = lightgray },
 }]
 \addplot table [x index=0, y index =1] {\america};
 \addplot table [x index=0, y index =2] {\america};
 \addplot+[nodes near coords, point meta=explicit] table [x index=0, y index =3, meta index=4] {\america};
\end{axis}
\end{tikzpicture}
\end{minipage}
\begin{minipage}{0.45\columnwidth}
\centering
\begin{tikzpicture}[scale = .5, transform shape]
\begin{axis}[
 xshift=3mm, ybar stacked,
 axis x line*=bottom, 
 symbolic x coords={a,b,c,d,e,f,g,h,i,j,z},
 ymin=0, 
 xticklabel = {\benchmark{\tick}},
 yticklabel={ $\pgfmathprintnumber{\tick}\,\%$ },
 xtick=data,
 x tick label style={rotate=45,anchor=east,font=\Large},
 y tick label style={font=\Large},
 title style={font=\Large},
 xtick align=outside,
 every node near coord/.append style = {
   anchor = west,    rotate = 90,
   font = {\Large},
   /pgf/number format/fixed,
 }, title={2},
 cycle list = {
   { fill = gray },
   { fill = darkgray },
   { fill = lightgray },
 }]
 \addplot table [x index=0, y index =1] {\europe};
 \addplot table [x index=0, y index =2] {\europe};
 \addplot+[nodes near coords, point meta=explicit] table [x index=0, y index =3, meta index=4] {\europe};

\end{axis}
\end{tikzpicture}
\end{minipage}
\label{fig:hashed-objects2}
\end{figure}
\end{document}

它产生了以下情节: 在此处输入图片描述

我想在两者之间添加更多水平空间。我已经读过这个使用 pgfplots,在图之间添加垂直/水平间距?,但在我的例子中,y 轴上有不同的刻度,我已经读过这个如何使用 pgfplots 在两个单独的图之间添加空间?它也没什么用。我已经花了好几个小时来解决这个问题了。非常感谢你的帮助。

答案1

尝试让两个minipagesa 都稍微宽一点,0.5\columnwidth并通过添加 来消除它们之间的空间%,即

\end{minipage}%  <-- % here removes a space
\begin{minipage}{0.5\columnwidth}

这两个图形都比它们所在的位置要宽一些minipage,通过给它们多一点空间,我在图形之间获得了更多的空间。

相关内容