
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}
この方法では、スタイルとデータが分離され、スタイルが再利用可能になります。