Math & ScienceBar Charts Symbolic Coords

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
Anna2013
Posts: 1
Joined: Sat Apr 27, 2013 2:08 pm

Bar Charts Symbolic Coords

Post by Anna2013 »

Hello,

I'm trying to make bar charts using pgfplots in TeXShop 2.47.

I tried typesetting the following example from the pgfplots manual and it worked fine:

Code: Select all

\documentclass[a4paper]{article}
\usepackage{pgfplots}
%I had to leave this line out though - \pgfplotsset{width=7cm,compat=1.8}
\usetikzlibrary{patterns}

\begin{document}

\begin{tikzpicture}
\begin{axis}
\addplot+[ybar] plot coordinates
{(0,3) (1,2) (2,4) (3,1) (4,2)};
\end{axis}
\end{tikzpicture}

\end{document}

But my bar charts need to have symbolic x coordinates, like this other example below.

Code: Select all

\usepackage{pgfplots}
\usetikzlibrary{patterns}

\begin{document}

\begin{tikzpicture}
\begin{axis}[
ybar,
enlargelimits=0.15,
legend style={at={(0.5,-0.15)},
anchor=north,legend columns=-1},
ylabel={\#participants},
symbolic x coords={tool8,tool9,tool10},
xtick=data,
nodes near coords,
nodes near coords align={vertical},
]
\addplot coordinates {(tool8,7) (tool9,9) (tool10,4)};
\addplot coordinates {(tool8,4) (tool9,4) (tool10,4)};
\addplot coordinates {(tool8,1) (tool9,1) (tool10,1)};
\legend{used,understood,not understood}
\end{axis}
\end{tikzpicture}

\end{document}
When I typeset that example I get the error message:
./Untitled.tex:21: Package PGF Math Error: Could not parse input 'tool9' as a floating point number, sorry. The unreadable part was near 'tool9'..


Does anyone know a way to get round this?

I guess TeXShop must use an old version of pgfplots, but I'm not sure which. I'm trying to find out how to install version 1.8 of pgfplots, but I haven't been able to move the pgfplots_1.8.tds download out of my User directory to put it with the LaTeX files. The terminal says permission denied.

I'd be very grateful if anyone could help.

Thanks in advance.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Bar Charts Symbolic Coords

Post by Johannes_B »

Your example works fine on my machine (after giving a
documentclass). You can find out about the versin number of your
packages by inserting \listfiles just
before \documentclass.

Your editor (TexShop) has nothing to do with the loading of
packages, this is done by pdflatex, comming with your
TeX-Distribution (MikTeX (only Windows) or Tex Live (nearly all
platforms)). Updating and installing
new packages can with the package manager. With TeX Live this is
done the fastest by typing into a terminal:

Code: Select all

sudo tlmgr update --all
You need super user rights and the location of the program
(tlmgr, Tex Live Manager) has be known by your shell.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
Post Reply