1

The following code output an error:

Argument of \XC@definec@lor has an extra }.
<inserted text> 
                \par 
l.26     \end{axis}

However, I cannot debug and find the code that causes the error.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{pgfplots}
% \usepgfplotslibrary{statistics}
\pgfplotsset{compat=1.14}
% \usepackage{tikz}
\usetikzlibrary{patterns}

\begin{document}

\begin{figure}[tb]
\centering
\hspace*{-0.32cm}
\begin{tikzpicture}[font=\scriptsize]
    \begin{axis}[ybar stacked,
    height=4.5cm,width=9cm,
    ymin=0,ymax=5,
    ylabel style = {align=center},
    ylabel={\# relevant score},
    symbolic x coords={Launch,Options,Text Input,Text\\Display,Fixed-item\\List,Dynamic-\\item List},
    xticklabel style={align=center},
    nodes near coords,
%   nodes near coords align={vertical},
%     nodes near coords style={/pgf/number format/fixed,
%     /pgf/number format/fixed zerofill,
%     /pgf/number format/precision=2},
%     every node near coord/.append style={font=\scriptsize},
    ]
        \addplot coordinates
            {(Launch,3.93) (Options,4) (Text Input,4.38) (Text\\Display,3.35) (Fixed-item\\List,3.44) (Dynamic-\\item List,4.32)};
    \end{axis}
\end{tikzpicture}
% \vspace*{-0.5cm}
\caption{Relevance evaluation result from experiment participants}
\label{fig:user_scores}
\end{figure}

\end{document}
1
  • You shouldn't use \\ in symbolic coords. That's a rather fragile command. Commented Apr 17, 2019 at 14:31

1 Answer 1

2

The issue is the line breaks. Similarly to this nice answer, you can define symbolic coordinates without them but put them in the labels.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{pgfplots}
% \usepgfplotslibrary{statistics}
\pgfplotsset{compat=1.14}
% \usepackage{tikz}
\usetikzlibrary{patterns}

\begin{document}

\begin{figure}[tb]
\centering
\hspace*{-0.32cm}
\begin{tikzpicture}[font=\scriptsize]
    \begin{axis}[ybar stacked,
    height=4.5cm,width=9cm,
    ymin=0,ymax=5,
    ylabel style = {align=center},
    ylabel={\# relevant score},
    symbolic x coords={Launch,Options,Text Input,
    Text Display,Fixed-item List,Dynamic-item List},
    xticklabels={,Launch,Options,Text Input,
    Text\\ Display,Fixed-\\item List,Dynamic-\\item List},
    xticklabel style={align=center},
    nodes near coords,
%   nodes near coords align={vertical},
%     nodes near coords style={/pgf/number format/fixed,
%     /pgf/number format/fixed zerofill,
%     /pgf/number format/precision=2},
%     every node near coord/.append style={font=\scriptsize},
    ]
        \addplot coordinates
            {(Launch,3.93) (Options,4) (Text Input,4.38)
             (Text Display,3.35)
            (Fixed-item List,3.44) (Dynamic-item List,4.32)
            };
    \end{axis}
\end{tikzpicture}
% \vspace*{-0.5cm}
\caption{Relevance evaluation result from experiment participants}
\label{fig:user_scores}
\end{figure}
\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .