# pgfplots errors when reading in data in standalone file

I'd appreciate any help with this. I've had a read of some similar problems, but not the same as mine. I'm trying to create an image using pgfplots, in a standalone .tex file. I have a CSV file, with data as shown below.

dt,dp,dE
1.000000000,0.000010000,-3.656612577
10.000000000,0.000010000,-2.656180402
100.000000000,0.000010000,-1.651866238
1000.000000000,0.000010000,-0.607901729
10000.000000000,0.000010000,0.903554942
100000.000000000,0.000010000,3.532851491
1.000000000,0.000100000,-3.693263127
10.000000000,0.000100000,-2.692898714
100.000000000,0.000100000,-1.689273832
1000.000000000,0.000100000,-0.652898064
10000.000000000,0.000100000,0.672648732
100000.000000000,0.000100000,1.546957027
1.000000000,0.001000000,-4.981641553
10.000000000,0.001000000,-3.981670379
100.000000000,0.001000000,-2.982019408
1000.000000000,0.001000000,-1.985481315
10000.000000000,0.001000000,-1.022172045
100000.000000000,0.001000000,-0.408245334
1.000000000,0.010000000,-6.524022325
10.000000000,0.010000000,-5.524522779
100.000000000,0.010000000,-4.524520125
1000.000000000,0.010000000,-3.524410901
10000.000000000,0.010000000,-2.523458696
100000.000000000,0.010000000,-1.517634245
1.000000000,0.100000000,-8.595381336
10.000000000,0.100000000,-7.538480264
100.000000000,0.100000000,-6.538303992
1000.000000000,0.100000000,-5.538261116
10000.000000000,0.100000000,-4.537841077
100000.000000000,0.100000000,-3.537098665
1.000000000,1.000000000,-10.540334260
10.000000000,1.000000000,-9.538196497
100.000000000,1.000000000,-8.540547543
1000.000000000,1.000000000,-7.540192616
10000.000000000,1.000000000,-6.539782772
100000.000000000,1.000000000,-5.539092363


My pgfplots code is

\documentclass[tikz]{standalone}
\usepackage{pgfplots,pgfplotstable}
\usepackage{siunitx}
\usepackage{amsmath}
\usepackage{physics}
\usetikzlibrary{matrix}
\usepgfplotslibrary{units}

\begin{document}

\begin{tikzpicture}
\begin{axis}[enlargelimits=false, colorbar,point meta = explicit,ymode=log,xmode=log,colorbar style={title=${\log_{10}(\flatfrac{\Delta E}{E_0})}$},axis on top,ylabel={Initial momentum, $p_x$}, y unit = {\si{\giga\electronvolt}}, x unit = {\si{\per\giga\electronvolt}},xlabel = {Timestep, $\Delta t$},xmin=0.316227766,xmax=316227.766,ymax=3.16227766,ymin=0.00000316227766]
\addplot[matrix plot,mesh/cols=6,mesh/rows=6] table[x = dt,y = dp,col sep = comma, meta = dE]{EnergyMatrixCromerALD.csv};
\end{axis}
\end{tikzpicture}
\end{document}


and the errors I get are

! Illegal unit of measure (pt inserted).
Y
l.15 ...omma, meta = dE]{EnergyMatrixCromerALD.csv};

Dimensions can be in units of em, ex, in, pt, pc,
cm, mm, dd, cc, nd, nc, bp, or sp; but yours is a new one!
I'll assume that you meant to say pt, for printer's points.
To recover gracefully from this error, it's best to
delete the erroneous units; e.g., type 2' to delete
two letters. (See Chapter 27 of The TeXbook.)

! Missing = inserted for \ifdim.
Y
l.15 ...omma, meta = dE]{EnergyMatrixCromerALD.csv};

I was expecting to see <', =', or >'. Didn't.

! Missing number, treated as zero.
Y
l.15 ...omma, meta = dE]{EnergyMatrixCromerALD.csv};

A number should have been here; I inserted 0'.
(If you can't figure out why I needed to see a number,
look up weird error' in the index to The TeXbook.)


This repeats for all data before stopping compilation. I'm baffled as to what it is reading as a unit. The compiler is LuaLaTeX, but the same thing happens in pdfLaTeX.

Any insight into what is going on would be greatly appreciated, whether it's an issue with my data, or with pgfplots.

Edit I've made a file from scratch, and found the issue to be in the xmin option. Why? I don't know.

• Which is the exact content of the csv file? I mean, the ---- row is not in the data, I suppose? – Rmano Mar 24 at 14:33
• The problem is related to the options xmode=log and ymode=log. Removing them makes the error disappear. – gernot Mar 24 at 15:09
• @Rmano yes you're quite right. The actual csv just has each data point arranged as in the table. Plain text, and the dt, dp, and dE are headers. – Sam Mar 24 at 15:19
• @gernot I have another very similar matrix plot which uses log-log and doesn't experience this same issue. The data also need to be shown on a log-log plot. – Sam Mar 24 at 15:20
• IIRC, col sep=comma is not the default. You may even need to load pgfplotstable to specify it. – John Kormylo Mar 24 at 20:31