1

I'm currently trying to make a plot of the function f(x,t)=exp(-((x)^2)/y)/sqrt(2*pi*y) in PGFplots.

As a first step I plotted this as a contourplot directly from the function (see code below). The problem however is that the plot is very coarse. The next step was to increase the number of samples up to 85 (maximum before LaTeX has a memory overflow). This however was still to coarse for my taste.

Currently I'm trying to make the contourplot smoother by making a table with another program (Mathematica), that I'm trying to input as a plotlist. The problem here however is that PGFplots doesn't accept my table, resulting in no plot at all. The .dat file I'm trying is of the form

x y z
0 0 f(0,0)
0 1 f(0,1)
0 2 f(0,2)
...
1 0 f(1,0)
1 1 f(1,1)
...

I have no idea what I'm doing wrong in the conversion to the table and I can't seem to find anything in the manual. I'm open for fresh ideas.

Yes the supplied data is numerical, the data is well behaved (no extreme large or small values), I have purely numerical data and I tried both the format with and without the header. The data was included for the plot using the typical

table {table.dat};

The code for my origional plot (which does work)

\documentclass[tikz]{standalone}
\usepackage{pgfplots}
\begin{document}
            \begin{tikzpicture}
                    \begin{axis}
                    [
                    colorbar,
                    colormap/hot2,
                    view = {0}{90},
                    ]
                        \addplot3[
                            contour filled={number = 10,labels={false}},
                            samples=31,
                            shader=interp,
                            ]
                             {exp(-((x)^2)/y)/sqrt(2*pi*y)};
                    \end{axis} 
                \end{tikzpicture} 
\end{document}
  • 2
    samples=21,samples y=21, looks OK to me. you can change the domain too. The table needs numbers then you can use table \mytable – percusse Jul 24 '17 at 14:44
  • @percusse With 21 samples it's a bit to wiggly for my taste. Reducing the plotrange is not an option since I'm comparing this to the propagator for other parameters. It's my first set of course notes and I'm to proud I think :(. If you want I can add the dataset that I'm trying to the question, I only don'k know how. The only thing I get is zig-zag lines. My guess is that LaTeX only uses the first two coordinates, not all. – Nick Jul 25 '17 at 6:31
  • @Symbol1 The list I provide to pgfplots is a list with three columns (x-values, y-values and z-values). For regular 2D plots this always worked just fine. I hope to get somekind of rectangular grid with this for the contourplot. Another thing that's going through my mind is to plot the contours (using contour prepared) and try to fill these up. The problem with the latter is that I don't know how to fill these contours then. – Nick Jul 25 '17 at 6:49
  • Sorry I misread your question. I deleted my comments. – Symbol 1 Jul 25 '17 at 16:15
  • @Symbol1 No problem, the more information, the better! – Nick Jul 26 '17 at 7:44

Your Answer

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

Browse other questions tagged or ask your own question.