
저는 pgfplots를 사용하여 일부 데이터를 막대 차트로 컴파일하려고 했습니다. 상황은 다음과 별개로 작동하는 것 같습니다. 막대에 대한 주석의 정밀도가 낮습니다. 즉, 소수점 이하 3자리만 표시되며 "1.02 \cdot 10^6"으로 표시됩니다. 실제값(1022641)으로 바꾸는 방법이 있나요?
\begin{tikzpicture}
\begin{axis}[
xbar, xmin=500000,
width=12cm,enlarge y limits=0.5,
xlabel={Travel time [s]},
symbolic y coords={hello},
ytick=data,
nodes near coords, nodes near coords align={horizontal},
]
\addplot coordinates {(1022641,hello)};
\end{axis}
\end{tikzpicture}
답변1
좋아, 결국 다음을 수행하게 되었습니다. 먼저 실제 외부 스타일을 정의했습니다 \tikzpicture
.
\pgfplotsset{
default style/.style={
xbar, xmin=0,
width=12cm,enlarge y limits=0.5,
xlabel={Travel time [s]},
ytick=data,
nodes near coords, nodes near coords align={horizontal},
every node near coord/.append style={/pgf/number format/.cd, fixed,1000 sep={}}
}
}
여기에는 percusse와 Jake가 제안한 수정 사항이 포함되어 있습니다. 실제 플롯은 정의된 스타일을 사용합니다.
\begin{tikzpicture}
\begin{axis}[
default style,
symbolic y coords={hello}
]
\addplot coordinates {(1022641,hello)};
\end{axis}
\end{tikzpicture}
이렇게 하면 스타일과 데이터가 분리되고 스타일을 재사용할 수 있습니다.