I would like to create a surface plot (like the one shown below) from a .csv table containing three columns of data (x,y,phi) but all I get is a line plot (see second picture). The data table is downloadable from the provided link. If anyone knows how to get around this issue your help would be much appreciated.what i would like to get

what i get in latex



\section{Contour Plot}

\begin{tikzpicture} \begin{axis}[
title={computational potential}, xmin=-3, xmax=3, ymin=0, ymax=3,
colorbar horizontal,
mesh/ordering=x varies,
\addplot3 [surf,
] table [col sep=comma] {computational_potential.csv}; \end{axis}


link to download .csv data


1 Answer 1


First I thought that because the data lies in lines, it does not span any surface, and can not be used. -but the different lines does span surface. Normally data would be formatted as

<x1> <y1> <z>
<x1> <y2> <z>
<x1> <y3> <z>

<x2> <y1> <z>
<x2> <y2> <z>
<x2> <y3> <z>

(from https://tex.stackexchange.com/a/50020/8650)

By inserting a single blank line in the data like this:

x   y   phi    


it triggers the surf to accept more than just the one line in space and generated this:


  • I would look into processing the data to conform with the correct format and not misuse a 3D surf plot for a 2D graph. Commented Jul 12, 2021 at 13:06
  • Thank you so much for your answer! (The main reason i tried using a 3d surf plot was only because it resulted in a slightly better output (relatively speaking) than a filled contour plot.)
    – albert1234
    Commented Jul 12, 2021 at 16:14
  • Please upvote and accept answer Commented Sep 12, 2021 at 17:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .