
それで、この例は のマニュアルからそのまま引っ張り出しましたpgfplots
。これは非常に複雑に見えるからです。グラフはまさに私が求めていたものですが、提供されているカスタム ラベルの代わりに、 の複合番号をBPChem
ラベルとして挿入できるようにしたいので、テストとして、まずそれをsymbolic x coord
自分の番号参照に置き換えました。言うまでもなく、うまくいきません :(
\documentclass[12pt, letterpaper]{article}
\usepackage{pgfplots}
\usepackage{bpchem}
\begin{document}
\CNlabelsubnoref{cmp1}{a}
\begin{tikzpicture}
\begin{axis}[
ybar,
enlargelimits=0.15,
legend style={at={(0.5,-0.2)},
anchor=north,legend columns=-1},
ylabel={\#participants},
symbolic x coords={\CNrefsub{cmp1}{a},good,neutral,%
not good,poor},
xtick=data,
nodes near coords,
nodes near coords align={vertical},
x tick label style={rotate=45,anchor=east},
]
\addplot coordinates {(\CNrefsub{cmp1}{a},0) (good,8)
(neutral,2) (not good,0) (poor,0)};
\end{axis}
\end{tikzpicture}
\end{document}
pdflatex のコンパイルは終了しませんが、pdf ファイルにはこれが含まれています...
pgfplots [ ybar、拡大制限=0.15、凡例スタイル=at=(0.5,-0.2)、アンカー=北、凡例列=-1、ylabel=参加者数、シンボリック x 座標=??、良好、中立、良好でない、不良、xtick=データ、座標付近のノード、座標付近のノード align=vertical、x 目盛りラベル スタイル=回転=45、アンカー=東、] 座標 (??、0) (良好、8) (中立、2) (良好でない、0) (不良、0); 1
pdflatex を停止すると、コンソールに次のエラーが表示されます。
! Missing \endcsname inserted.
<to be read again>
\protect
l.20 ]
The control sequence marked <to be read again> should
not appear between \csname and \endcsname.
Missing character: There is no a in font nullfont!
! Extra \endcsname.
\pgfplotsarray@glob@TMP ...ts@loc@TMPa \endcsname
Process exited with error(s)
これを回避できる可能性はありますか?
答え1
symbolic x coords
アプローチを使用するのではなく、 を\coordindex
x 座標として使用し、 を使用して x 目盛りラベルを指定することをお勧めしますxticklabels={\CNrefsub{cmp1}{a}, good, neutral, not good, bad}
。
\documentclass[12pt, letterpaper]{article}
\usepackage{pgfplots}
\usepackage{bpchem}
\begin{document}
\CNlabelsubnoref{cmp1}{a}
\begin{tikzpicture}
\begin{axis}[
ybar,
enlargelimits=0.15,
legend style={at={(0.5,-0.2)},
anchor=north,legend columns=-1},
ylabel={\#participants},
xtick=data,
nodes near coords,
nodes near coords align={vertical},
x tick label style={rotate=45,anchor=east},
xticklabels={\CNrefsub{cmp1}{a}, good, neutral, not good, bad}
]
\addplot table [
x expr=\coordindex, % Use the row number as x coordinate
header=false % Do not assume the first row to contain column names
] {
cmp 0
good 8
neutral 2
notgood 0
bad 0
};
\end{axis}
\end{tikzpicture}
\end{document}