tikzpicture - 将堆叠的条形图与 y 轴对齐,ymin = 0

tikzpicture - Align stacked barplot to y-axis with ymin=0

我正在尝试制作一个与 tikzpicture 的 y 轴对齐的堆叠条形图。

\begin{tikzpicture}
\begin{axis}[
    ybar stacked,
    bar width=15pt,
    ymin=29,
    nodes near coords,
    enlargelimits=0.15,
    legend style={at={(0.5,-0.15)},
      anchor=north,legend columns=-1},
    ylabel={Seconds (s)},
    symbolic x coords={t1, t2, t3, t4},
    xtick=data,
    x tick label style={rotate=45,anchor=east},
    ]
    \addplot+[ybar] plot coordinates {(t1, 143) (t2, 203) (t3, 174) (t4, 188)};
    \addplot+[ybar] plot coordinates {(t1, 34) (t2, 36) (t3, 39) (t4, 35)};
  \legend{\strut S1,\strut  S2}
  \end{axis}
\end{tikzpicture}

如图所示,我使用 ymin 强制它靠近 y 轴,但它看起来并不完美。另外,我希望能够自动执行此操作,因为我有很多图形需要此配置,而手动操作需要时间。

ymin=0 且没有额外扩大此限制:

\documentclass{article}

\usepackage{pgfplots}

\begin{document}


\begin{tikzpicture}
\begin{axis}[
    ybar stacked,
    bar width=15pt,
    ymin=0,
    nodes near coords,
%    enlargelimits=0.15,
    legend style={at={(0.5,-0.15)},
      anchor=north,legend columns=-1},
    ylabel={Seconds (s)},
    symbolic x coords={t1, t2, t3, t4},
    xtick=data,
    x tick label style={rotate=45,anchor=east},
    ]
    \addplot+[ybar] plot coordinates {(t1, 143) (t2, 203) (t3, 174) (t4, 188)};
    \addplot+[ybar] plot coordinates {(t1, 34) (t2, 36) (t3, 39) (t4, 35)};
  \legend{\strut S1,\strut  S2}
  \end{axis}
\end{tikzpicture}

\end{document}