PGFPLOT 막대 그래프 위치 범례 및 다른 표기법

PGFPLOT 막대 그래프 위치 범례 및 다른 표기법

막대 그래프와 위치 범례에 대해 문의하고 싶습니다.

\usepackage{pgfplots}
    \begin{document}
    \begin{tikzpicture}
      \begin{axis}
        [ xbar,
        %enlargelimits=0.14,width=8cm,height=6cm,,
            bar width=10pt,area legend,legend pos=south east,
            legend style={cells={anchor=west}}, area legend,
            tick align=outside,xlabel=\textbf{EUR Billion},
            ytick={1,...,3},
            yticklabel style={text width=3.3cm,align=right},
            yticklabels={Automotive \& Aircraft,
                                        Building Sector,ICT}]

      \addplot[draw=blue,fill=blue!15]
                        coordinates {(42,1) (34.5,2) (42,3)};

        \addlegendentry{\textsc{2016}}

        \addplot[draw=blue,fill=blue!50]
                        coordinates {(16.5,1) (15,2) (11.25,3)};


        \addlegendentry{\textsc{2006}}
    \end{axis}
    \end{tikzpicture}

나는 이것을 가지고있다: 나 이거 갖고 있어

하지만 나는 다음을 원합니다: 나는 이것을 원한다

시간을 내어 도움을 주셔서 미리 감사드립니다. 두 번째 그림은 그림판에서 변경되었습니다.

답변1

범례의 순서는 플롯의 순서와 일치하며 옵션을 통해 되돌릴 수 있습니다 reverse legend. 범례 위치는 를 통해 수정할 수 있습니다 legend style={at={(x,y)}}. 는 정규화된 좌표 x입니다 y. 아래 코드를 참조하세요.

\documentclass[border=10pt]{standalone}
\usepackage{pgfplots}
\begin{document}
    \begin{tikzpicture}
    \begin{axis}
        [ xbar,
            bar width=10pt,area legend,legend pos=south east,
            reverse legend,
            legend style={cells={anchor=west},at={(0.99,0.42)}}, area legend,
            tick align=outside,xlabel=\textbf{EUR Billion},
            ytick={1,...,3},
            yticklabel style={text width=3.3cm,align=right},
            yticklabels={Automotive \& Aircraft,
                                        Building Sector,ICT}]

        \addplot[draw=blue,fill=blue!15]
            coordinates {(42,1) (34.5,2) (42,3)};
        \addlegendentry{\textsc{2016}}                            

        \addplot[draw=blue,fill=blue!50]
            coordinates {(16.5,1) (15,2) (11.25,3)};
        \addlegendentry{\textsc{2006}}

    \end{axis}
    \end{tikzpicture}
\end{document}

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

관련 정보