I am trying to use gnuplot within pgfplots to draw contour plots for a data file. The contour curves are unfortunately not smooth enough, and the additional limitation is the size of the data file (a 41 x 41 grid at present). A typical MWE for my code would be:




scale only axis,
axis x line*=bottom,
axis y line*=left,
axis z line*=left,
contour gnuplot={%
draw color=black,
mesh/cols=42] table[header=false]{datfile.dat};

Using the handler option from PGFPlots manual has not helped in this case. If, however, I use the smooth option in the axis environment, I get zigzag lines throughout the graph.

If there is no way to solve this problem within PGFPlots, I was wondering if there is some other route available by:

1) either calling programs like gnuplot or matlab etc. from within PGFPlots, or

2) using smooth, interpolated contour plots to begin with, through Mathematica or similar.

Any suggestions in either direction, or any better solution, would be helpful and greatly appreciated. Thank you!

EDIT: The contour plot generated from above code contour_plot[2]

Link to data file.

  • Can you make your code complete with the preamble? Just the necessary packages for this code. – Alenanno Mar 5 '16 at 0:22
  • Included preamble and packages used. Would it help to add the datfile.dat too? Thank you. – smike Mar 5 '16 at 13:00
  • If your plot uses that data, yes thanks. You can paste it and then add the code formatting to it. – Alenanno Mar 5 '16 at 13:19
  • I have included the contour plot. Couldn't copy-paste the data file, it was too large for the comments section. I will try to include it on some file hosting site and link here. – smike Mar 5 '16 at 13:41
  • Included the data file too now. – smike Mar 5 '16 at 13:47

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.