我正在尝试绘制一个条形图,pgfplots
我想在其中添加对 x 坐标的引用。输出中出现以下错误。
Paragraph ended before \XC@definec@lor was complete
和Argument of \XC@definec@lor has an extra }. \end{axis}
但是,当我删除引文时,一切似乎都正常。这是 MWE。
\begin{tikzpicture}
\begin{axis}[
ybar,
enlargelimits=0.15,
legend style={at={(0.5,-0.2)},
anchor=north,legend columns=-1},
ylabel={Normalized Cost},
symbolic x coords={A,\cite{somework},\cite{otherwork}},
width={\textwidth},
xtick=data,
nodes near coords,
nodes near coords align={vertical},
]
\addplot coordinates {(A,1) (\cite{somework},2) (\cite{otherwork},3)};
\end{axis}
\end{tikzpicture}
\usepackage{tikz,pgfplots}
我在序言中已经使用过。
答案1
不要使用symbolic x coords
,而要使用 xtick
和xticklabels
。
tikz
(顺便说一下,您不需要明确加载,pgfplots
它会为您完成。)
% arara: pdflatex
% arara: biber
% arara: pdflatex
\documentclass{article}
\usepackage{pgfplots}
\usepackage{biblatex}
\addbibresource{xampl.bib}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
ybar,
enlargelimits=0.15,
legend style={at={(0.5,-0.2)},
anchor=north,legend columns=-1},
ylabel={Normalized Cost},
xtick={1,2,3},
xticklabels={A,\cite{article-full},\cite{book-full}},
width={\textwidth},
nodes near coords,
nodes near coords align={vertical},
]
\addplot coordinates {(1,1) (2,2) (3,3)};
\end{axis}
\end{tikzpicture}
\end{document}