I've been trying to make a ybar plot with error bar using pgfplots. I want to make this graph inside a tex template, but one weird thing has occurred - when I inserted the following code (be more specific - inserted only tikzpicture and its content) into the template this error message occurred:

! Use of \pgfplots@foreach@plot@coord@NEXT@plusminus doesn't match its definition.



\begin{axis} [%log ticks with fixed point
,symbolic x coords={Lighting,Computers,Total}]
\addplot+[only marks] plot[error bars/.cd, y dir=both, y explicit]
    (Lighting,0.12) +- (0.31,0.03)
    (Computers,0.06) +- (0.12,0.01) 
    (Total,0.07) +- (0.14,0.02)


(The code is taken from pgfplots with symbolic x coords and error bars .)

When I inserted this code into a separate tex file, everything works fine and it produced a graph.

I know that one solution is to make the graph in an external file and then import it, but I am asking what can cause this error message (I'm still novice to tex, yet read manual for pgfplots) and if there is a way to get it to work.

I've tried to google it but found nothing. Also I've tried to change order of items in the preamble in the main file. The preamble looks like this:

\usepackage{txfonts, cleveref}


I'm intentionally not posting the template because it would be simpler to import the graph from external file for me than for someone to read through a template.

  • 1
    but then we don't know what might go wrong because it works as it is. Also current version of pgfplots is 1.10
    – percusse
    Commented Aug 5, 2014 at 21:19
  • Sometimes packages modify characters such that they do stuff ("become active"). You might help us to identify if this is the root cause by adding \catcode\-=12 somewhere before the offending plot (or the offending figure). This will restore the character handling for -. If this is the case, we have to identify the package which redefined the -` char. Commented Aug 6, 2014 at 21:19
  • Ch. Feuersänger - great it works! Thansk for support. I tried to comment other packages and the bug seems to be inside the template. percusse - However, I was unable to upload the whole template on writelatex.
    – Ell
    Commented Aug 7, 2014 at 12:26
  • @ChristianFeuersänger Hi, apparently your solution worked. Want to make it an answer and take the Q off the list of unanswered?
    – Johannes_B
    Commented Feb 11, 2015 at 21:58

1 Answer 1


The problem is causes by catcode reassignments in the template: some code changes uses something like


which causes TeX to change the meaning of the minus character -. Any occurrence of this character will be different from before -- and pgfplots uses it inside of the error bar input specification.

The solution is to change it back before using pgfplots (by means of \catcode\-=12) or by eliminating the catcode hackery.

Note that catcode changes inherently cause problems of this sort and are generally not a good practise. There are cases where their use outweighs their price (namely incompatibility with lots of other packages). But if possible: refrain from catcode changes.

  • 1
    If the document loads babel for Czech or Slovak, the hyphen becomes a shortcut and will cause the mentioned problem. If PGF version 3.0.0 is used, \usetikzlibrary{babel} will solve the issue in this case.
    – egreg
    Commented Feb 12, 2015 at 22:38

You must log in to answer this question.

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