Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

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)};
        \addplot[mark=none]
            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}]%
        \addplot3[contour gnuplot]%
            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?

share|improve this question
2  
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}. –  Christian Hupfer Jun 12 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. –  Munin Jun 12 at 14:16
1  
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. –  Torbjørn T. Jun 12 at 19:28
    
(Sorry, that was of course supposed to be labels over line, without the thick.) –  Torbjørn T. Jun 12 at 19:36
    
Ok, I've added a filecontents*. The plot that uses the CSV-file for a "normal" drawing is just to test the read out from the file. If you don't uncomment the addplot3-lines it should be compilable. –  Munin Jun 12 at 21:28

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.