3

I want to draw a table/matrix of color-values, where some of the values are missing. Despite having tried using unbounded coords=jump (see this answer), I get the following error:

! Missing number, treated as zero.
<to be read again>
                  n
l.59 \end{axis}

How do I tell pgfplots to include the rows and columns for the missing value, and simply skip those missing value?

Here's my MWE:

\documentclass{standalone}

\usepackage{filecontents}
\usepackage{pgfplots, pgfplotstable}

\begin{filecontents}{data.csv}
yitem,xitem,val
a,R,0.1
b,S,nan
c,T,0.3
d,U,nan
e,V,0.5
f,W,0.6
g,X,nan
h,Y,0.8
i,Z,nan
\end{filecontents}

\pgfplotstableread[col sep=comma]{data.csv}\datatable

\begin{document}
\begin{tikzpicture}
\begin{axis}[
    symbolic x coords={R,S,T,U,V,W,X,Y,Z},
    xtick=data,
    symbolic y coords={a,b,c,d,e,f,g,h,i},
    ytick=data,
    unbounded coords=jump,
]
\addplot[
    mark=square*,
    only marks,
    scatter,
    point meta=explicit,
] table [
    col sep=comma,
    x expr=\coordindex,
    y expr=\coordindex,
    meta expr=\thisrow{val},
] {\datatable};

\end{axis}
\end{tikzpicture}
\end{document}

I got the basic idea for the matrix/table from this page.

I have added \listfiles to my preamble and received the following pgf-looking output:

pgfplots.sty    2011/12/29 v1.5.1 (git show 1.5.1-4-g53e640f )
     pgf.sty    2008/01/15 v2.10 (rcs-revision 1.12)
  pgfrcs.sty    2010/10/25 v2.10 (rcs-revision 1.24)
  pgfrcs.code.tex
 pgfcore.sty    2010/04/11 v2.10 (rcs-revision 1.7)
  pdftex.def    2011/05/27 v0.06d Graphics/color for pdfTeX
  pgfsys.sty    2010/06/30 v2.10 (rcs-revision 1.37)
  pgfsys.code.tex
pgfsyssoftpath.code.tex    2008/07/18  (rcs-revision 1.7)
pgfsysprotocol.code.tex    2006/10/16  (rcs-revision 1.4)
 pgfcore.code.tex
pgfcomp-version-0-65.sty    2007/07/03 v2.10 (rcs-revision 1.7)
pgfcomp-version-1-18.sty    2007/07/23 v2.10 (rcs-revision 1.1)
  pgffor.sty    2010/03/23 v2.10 (rcs-revision 1.18)
 pgfkeys.sty
 pgfkeys.code.tex
  pgffor.code.tex
pgfplotstable.sty    2011/12/19 Part of pgfplots
  • 2
    I don't get an error when running this code. What version of PGFPlots are you using? – Jake Jan 13 '14 at 15:12
  • I added some output. It looks like its version 1.5.1 – derabbink Jan 13 '14 at 15:24
  • 2
    The current version is 1.9. Could you update the package and check whether the error persists? – Jake Jan 13 '14 at 15:24
  • I updated to 1.9 as you suggested, and now it works. If you want to type that up as an answer, I'll make sure to accept it. – derabbink Jan 14 '14 at 8:56
2

This requires a more recent version of PGFPlots (the current one is 1.9).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.