[Tex/LaTex] TikZ datavisualization example fails

debuggingtikz-datavisualizationtikz-pgf

While trying an example from the datavisualization section of the current TikZ manual I get a strange error message. On my system I have the current MikTeX 2.9 and installed the CVS version of TikZ (CVS 2012-05-18 from texample.net) according to this question: How to install a current version of TikZ?

Now the first part of the following MWE fails, whereas the second part runs nicely and I do not have any idea why.

\listfiles
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{datavisualization}

\begin{document}

\begin{tikzpicture}
  \datavisualization [school book axes, visualize as smooth line]
     data [format=function] {
     var x : interval [-2:2];
     func y = \value x*\value x + 1;
     };
\end{tikzpicture}

\begin{tikzpicture}
  \datavisualization [school book axes, visualize as smooth line]
    data {
    x, y
    -1.5, 2.25
    -1, 1
    -.5, .25
    0, 0
    .5, .25
    1, 1
    1.5, 2.25
    };
\end{tikzpicture}

\end{document}

The error message I receive from pdflatex or lualatex is

! Package pgf Error: Unknown data format 'function'.

See the pgf package documentation for explanation.
Type  H <return>  for immediate help.
 ...

l.10      data [format=function]

It works nicely, when the first tikzpicture environment is commented out and lists what I think are the current files from TikZ:

 article.cls    2007/10/19 v1.4h Standard LaTeX document class
  size10.clo    2007/10/19 v1.4h Standard LaTeX file (size option)
    tikz.sty    2012/05/14 v2.10-cvs (rcs-revision 1.99)
     pgf.sty    2008/01/15 v2.10-cvs (rcs-revision 1.12)
  pgfrcs.sty    2010/11/07 v2.10-cvs (rcs-revision 1.25)
everyshi.sty    2001/05/15 v3.00 EveryShipout Package (MS)
  pgfrcs.code.tex
 pgfcore.sty    2010/04/11 v2.10-cvs (rcs-revision 1.7)
graphicx.sty    1999/02/16 v1.0f Enhanced LaTeX Graphics (DPC,SPQR)
  keyval.sty    1999/03/16 v1.13 key=value parser (DPC)
graphics.sty    2009/02/05 v1.0o Standard LaTeX Graphics (DPC,SPQR)
    trig.sty    1999/03/16 v1.09 sin cos tan (DPC)
graphics.cfg    2007/01/18 v1.5 graphics configuration of teTeX/TeXLive
  pdftex.def    2011/05/27 v0.06d Graphics/color for pdfTeX
infwarerr.sty    2010/04/08 v1.3 Providing info/warning/error messages (HO)
 ltxcmds.sty    2011/11/09 v1.22 LaTeX kernel commands for general use (HO)
pdftexcmds.sty    2011/11/29 v0.20 Utility functions of pdfTeX for LuaTeX (HO)
ifluatex.sty    2010/03/01 v1.3 Provides the ifluatex switch (HO)
   ifpdf.sty    2011/01/30 v2.3 Provides the ifpdf switch (HO)
luatex-loader.sty    2010/03/09 v0.4 Lua module loader (HO)
  pgfsys.sty    2012/03/30 v2.10-cvs (rcs-revision 1.38)
  pgfsys.code.tex
pgfsyssoftpath.code.tex    2008/07/18  (rcs-revision 1.7)
pgfsysprotocol.code.tex    2006/10/16  (rcs-revision 1.4)
  xcolor.sty    2007/01/21 v2.11 LaTeX color extensions (UK)
   color.cfg    2007/01/18 v1.5 color configuration of teTeX/TeXLive
 pgfcore.code.tex
pgfcomp-version-0-65.sty    2007/07/03 v2.10-cvs (rcs-revision 1.7)
pgfcomp-version-1-18.sty    2007/07/23 v2.10-cvs (rcs-revision 1.1)
  pgffor.sty    2012/01/09 v2.10-cvs (rcs-revision 1.21)
 pgfkeys.sty
 pgfkeys.code.tex
 pgfmath.sty
 pgfmath.code.tex
  pgffor.code.tex
    tikz.code.tex
supp-pdf.mkii

What further steps should I take to debug this problem?

Best Answer

I just spent two hours tracking this down. (This is my first time using TikZ.)

You were right to ensure that you have the CVS (under development) version 2012-05-18 from texample.net.

Now add this line:

\usetikzlibrary{datavisualization.formats.functions}

This worked for me, running LaTeX on OSX (TeX Live 2012). If it doesn't work for you, try:

\usepgflibrary{datavisualization.formats.functions}

instead, possibly preceded by \usepackage{pgfcore} and whatever else you normally put in the preamble to use TikZ.

It appears that the datavisualization section of the manual hasn't yet been updated to tell which libraries or modules you need to load.

Related Question