0

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

\documentclass[12pt,a4paper]{report}
\usepackage[utf8]{inputenc}
\usepackage{filecontents}
\usepackage{pgfplots}

\pgfplotsset{compat=1.17} \begin{document}

\section{Contour Plot}

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

\end{document}

link to download .csv data

Stefan Pinnow
  • 29,535

1 Answers1

0

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    
0.5,0,0.96965

0.58333,0,0.98098 0.66667,0,1.0104 0.75,0,1.0514 0.83333,0,1.1005 ...

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

Graph