# Shell Scheme with pgfplots/gnuplot

I have a problem with pgfplots. I want to create a shell scheme from an E-motor characteristics. In the end it should look like this (well, with some more pleasing colours): shell scheme example http://www.compact-dynamics.de/uploads/RTEmagicC_Wirkungsgradkennfeld_deutsch.jpg.jpg

The data is stored in a .CSV-file.

n_max/min-1,M_max/Nm,eta1
1000,10,0.64
1000,20,0.72
1000,30,0.75
1000,40,0.76
2000,10,0.71
2000,20,0.78
2000,30,0.81
2000,40,0.83


And this is the TeX code that stresses me

\documentclass{article}

\usepackage[latin1]{inputenc}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{width=7cm,compat=1.8}
\usepgfplotslibrary{patchplots}

\begin{filecontents*}{example.csv}
n_max/min-1,M_max/Nm,eta1
1000,10,0.64
1000,20,0.72
1000,30,0.75
1000,40,0.76
2000,10,0.71
2000,20,0.78
2000,30,0.81
2000,40,0.83
\end{filecontents*}

\begin{document}
\pagestyle{empty}

\begin{figure}
\begin{tikzpicture}
\centering
\begin{axis}[
xlabel=$$n~\mathrm{in~min^{-1}}$$, xmin=0, xmax=12000,
ylabel=$$M~\mathrm{in~Nm}$$, ymin=0, ymax=140,
legend pos = south east,
scaled ticks = false,
view={0}{90},
height=0.7\textwidth,width=1.0\textwidth]
% max values for torque and revs
\addplot[mark=none, very thick, color=gray, domain = 0:5160]{130};
\addplot[mark=none, very thick, color=gray, domain = 5140:12000]{(60*70000)/(2*3.14159*x)};
table [x=n_max/min-1, y=M_max/Nm, col sep=comma] {example.csv};
%\addplot3[contour gnuplot={levels={0.7,0.8},labels over line,number=9},thick]
%   table [x=n_max/min-1, y=M_max/Nm, z=eta1, col sep=comma] {example.csv};
\end{axis}
\end{tikzpicture}
\end{figure}

\end{document}


After compiling LaTeX just says

! Package pgfplots Error: Sorry, processing the input stream did not lead to en
d-of-scanline markers; the generated temporary file for 'contour external' does
not contain any of them (indicating that matrix structure is lost). To fix thi
s, you have the following options:
- Insert end-of-scanline markers into your input data (i.e. empty lines),
- provide two of the three options 'mesh/rows=<num matrix rows>, mesh/cols=<nu
m matrix cols>, mesh/num points=<total number points>'.

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


An example from pgfplots manual (page 138 of version 1.10) produces the same errors.

\documentclass{article}
\usepackage[latin1]{inputenc}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{width=7cm,compat=1.8}
\usepgfplotslibrary{patchplots}

\begin{document}
\begin{tikzpicture}%
\begin{axis}[view={0}{90}]%
coordinates {
(0,0,0) (1,0,0) (2,0,0) (3,0,0)
(0,1,0) (1,1,0.6) (2,1,0.7) (3,1,0.5)
(0,2,0) (1,2,0.7) (2,2,0.8) (3,2,0.5)
};
\end{axis}%
\end{tikzpicture}%
\end{document}


I think the problem is, that gnuplot isn't able to read out the separate data points. Some experimenting with mesh/rows and mesh/cols has shown, that LaTeX interprets one line of the CSV-file as one column instead of three.

Can anyone help me with this?

• Welcome to TeX.SX! Please help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}.
– user31729
Jun 12 '14 at 9:50
• Hi Christian, I've changed the code so that it should compilable. For this I've uncommented the 3D-plot based on the CSV-file. Jun 12 '14 at 14:16
• I think there was a bit more to the error message, so I edited in the message I got. Note also that the thick labels over line and number= keys are undefined so I couldn't test the example as-is. Perhaps you could add those to the code. Jun 12 '14 at 19:28
• (Sorry, that was of course supposed to be labels over line, without the thick.) Jun 12 '14 at 19:36
• The example from the manual of pgfplots works for me when I add empty lines between the coordinate lines. It looks like you made a copy/paste mistake here, as the empty lines appear in the manual, too. Jun 23 '14 at 20:43

As @mvkorpel suggested, pgfplots fails to detect the matrix structure. The copy/paste of the example from the manual lost the empty lines.
Your example also lacks indication of matrix structure, that's why pgfplots suggests two alternatives
• provide two of the three options mesh/rows=<num matrix rows>, mesh/cols=<num matrix cols>, mesh/num points=<total number points>.
If you insert empty lines after each scan line, it works. Alternatively, if you say mesh/rows=2, it will work as well.