![PGFPLOT 막대 그래프 위치 범례 및 다른 표기법](https://rvso.com/image/328809/PGFPLOT%20%EB%A7%89%EB%8C%80%20%EA%B7%B8%EB%9E%98%ED%94%84%20%EC%9C%84%EC%B9%98%20%EB%B2%94%EB%A1%80%20%EB%B0%8F%20%EB%8B%A4%EB%A5%B8%20%ED%91%9C%EA%B8%B0%EB%B2%95.png)
막대 그래프와 위치 범례에 대해 문의하고 싶습니다.
\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}