[Tex/LaTex] Basic bar chart with text as x axis labels

graphspgfplots

I am trying to create a very basic bar chart using pgfplots. I need four bars representing percentages with text as labels under the x axis. Text labels contain spaces and accented, non-English characters.

Since I use pgfplots for all other charts in my paper I thought I'd give a shot at this one, too. However, since this chart uses non-numeric x values it's a little tricky. I'm trying to start with a text book example and go from there. Here's the example from the pgfplots manual (4.20.1 on p. 210) I'm trying to use:

\documentclass[12pt,a4paper,oneside]{article}

\usepackage{pgfplots}
\pgfplotsset{width=7cm,compat=1.3}

\begin{document}

\begin{tikzpicture}
\begin{axis}[symbolic x coords={a,b,c,d,e,f,g,h,i}]
\addplot+[smooth] coordinates {
(a,42)
(b,50)
(c,80)
(f,60)
(g,62)
(i,90)};
\end{axis}
\end{tikzpicture}

\end{document}

I have major problems with this code. For starters, TeXmaker hangs while trying to compile, I have to kill the pdflatex process to reanimate it. When I do I get the following error messages:

! Package pgfkeys Error: I do not know the key '/pgfplots/compat' and I am goin
g to ignore it. Perhaps you misspelled it.

! Package PGF Math Error: Could not parse input 'a' as a floating point number,
sorry. The unreadable part was near 'a'..

If someone could shed some light on what I'm doing wrong I'd most appreciate it. I am using a recent version of Ubuntu and TeX Live (2009-10). I have been using them for a year or so, never had a hang issue so far.

Recommendations for any other solution (preferably without any external program) are also welcome and appreciated. Thanks.

Best Answer

The version of pgfplots that is included in Ubuntu 10.10 is 1.2.2. Apparently the feature that you are using was added between then and version 1.4.1 (which is the current version).

Unless someone comes up with a workaround to add text coordinates in pgfplot 1.2, the easiest option for you is probably to upgrade to TeX Live 2010. Installing it manually isn't too hard and you will get all the newest versions. PGF related packages changed a lot since the TeX Live version that is included in Ubuntu. Also, you will be able to run tlmgr update --self --all to update your TeX installation at any time.


Here is a proof-of-concept with version 1.4 (I don't know pgfplots well, so there might be a better way to do this):

\documentclass{article}
\usepackage{pgfplots}

\begin{document}

\begin{tikzpicture}
\begin{axis}[
    symbolic x coords={a small bar,a medium bar,a large bar},
    xtick=data]
    \addplot[ybar,fill=blue] coordinates {
        (a small bar,42)
        (a medium bar,50)
        (a large bar,80)
    };
\end{axis}
\end{tikzpicture}

\end{document}

example