pfgplot 막대 그래프를 x축과 같은 높이로 만드는 방법은 무엇입니까?

pfgplot 막대 그래프를 x축과 같은 높이로 만드는 방법은 무엇입니까?

동일한 형식으로 보이는 이 두 가지가 왜 pfgplots출력이 다른지 아시나요? 대부분 나는 오른쪽 플롯처럼 y축(왼쪽 플롯)의 0이 x축과 같은 높이가 되도록 하고 싶습니다. 이 문제를 어떻게 해결할 수 있나요?

    \usepackage{graphicx}
    \usepackage{pgfplots}
    \usepackage{tikz}

    \begin{figure}[htb]
        \centering
        \makebox[0pt][c]{%
        \hspace{-2cm}
        \begin{minipage}[b]{0.5\linewidth}
        \centering
          \begin{tikzpicture}
                \begin{axis}[
                    ybar,
                    enlargelimits=0.15,
                    legend style={at={(0.5,-0.15)},
                      anchor=north,legend columns=-1},
                    ylabel={Collision score},
                    symbolic x coords={Large, 1, 2, 3, 33, 37},
                    xtick=data,
                    nodes near coords,
                    nodes near coords align={vertical},
                    point meta=y *10^-2
                ]
                \addplot 
                    coordinates {(Large,6.069e3) (1,1.311e3) (2,.146e3)
                         (3,.066e3) (33,.060e3) (37,.067e3)};
                \legend{Base}
                \end{axis}
            \end{tikzpicture}
        \label{sva}
        \end{minipage}%
        \hspace{1.5cm}
        \begin{minipage}[b]{0.5\linewidth}
        \centering
         \begin{tikzpicture}
                \begin{axis}[
                    ybar,
                    enlargelimits=0.15,
                    legend style={at={(0.5,-0.15)},
                      anchor=north,legend columns=-1},
                    ylabel={Elapsed Time},
                    symbolic x coords={Large, 1, 2, 3, 33, 37},
                    xtick=data,
                    nodes near coords,
                    nodes near coords align={vertical},
                ]
                \addplot 
                    coordinates {(Large,0.115 ) (1,0.124) (2,0.104 )
                         (3,0.108) (33,0.099) (37,0.103)};
                \legend{Base}
                \end{axis}
            \end{tikzpicture}
        \label{svb}
        \end{minipage}%
        }%
    \end{figure}

여기에 이미지 설명을 입력하세요

답변1

이는 때문이지만 enlargelimits오른쪽 축의 y는 0에서 시작하지 않습니다. 따라서 약간의 수정으로 원하는 결과를 얻을 수 있습니다. 이에 대해서는 코드의 주석을 참조하세요.

% used PGFPlots v1.16
\documentclass[border=5pt]{standalone}
\usepackage{pgfplots}
    \pgfplotsset{
        my axis style/.style={
            ybar,
            enlarge x limits=0.15,      % <-- changed
            legend style={
                at={(0.5,-0.15)},
                anchor=north,
                legend columns=-1,
            },
            symbolic x coords={Large, 1, 2, 3, 33, 37},
            xtick=data,
            nodes near coords,
            nodes near coords align={vertical},
        },
    }
\begin{document}
\begin{tikzpicture}
    \begin{axis}[
        my axis style,
        ymin=0,                         % <-- added
        ylabel={Collision score},
        point meta=y *10^-2
    ]
    \addplot
        coordinates {(Large,6.069e3) (1,1.311e3) (2,.146e3)
             (3,.066e3) (33,.060e3) (37,.067e3)};
    \legend{Base}
    \end{axis}
\end{tikzpicture}
\begin{tikzpicture}
    \begin{axis}[
        my axis style,
        ylabel={Elapsed Time},
    ]
        \addplot coordinates {
            (Large,0.115 ) (1,0.124) (2,0.104)
             (3,0.108) (33,0.099) (37,0.103)};
        \legend{Base}
    \end{axis}
\end{tikzpicture}
\end{document}

위 코드의 결과를 보여주는 이미지

관련 정보