2

I have data that is basically 3D (x,y, and temperature), a simple top view 3D plot in pgfplots

\documentclass{standalone}

\usepackage{tikz,pgfplots}

\begin{document}
 \begin{tikzpicture}
  \begin{axis}[view={0}{90}]
   \addplot3[surf] coordinates {
     (-1.5,-1.5, 20) (-0.5,-1.5,21)  (0.5,-1.5, 22) (1.5,-1.5,21) 

     (-1.5,-0.5, 21) (-0.5,-0.5,23)  (0.5,-0.5, 22) (1.5,-0.5,20) 

     (-1.5,0.5, 22) (-0.5,0.5,23)  (0.5,0.5, 24) (1.5,0.5,21) 

     (-1.5,1.5, 21) (-0.5,1.5,20)  (0.5,1.5, 21) (1.5,1.5,22) 
  };
  \end{axis}
 \end{tikzpicture}
\end{document}

looks like this:

enter image description here

However, each of the points represents a 1x1 square, so the plot above should have 16 instead of 9 tiles, and span from (-2,-2) to (2,2).

How can I do that?

Stefan Pinnow
  • 29,535
Christoph
  • 2,913

1 Answers1

2

For this type of plot, you should use the matrix plot option (if you want the y axis to run from top to bottom) or matrix plot* (if you want the y axis to run from bottom to top):

\documentclass{standalone}

\usepackage{pgfplots}

\begin{document}
 \begin{tikzpicture}
  \begin{axis}[
    view={0}{90},
    axis equal image,
    colormap/viridis
  ]
   \addplot3[matrix plot*] coordinates {
     (-1.5,-1.5, 20) (-0.5,-1.5,21)  (0.5,-1.5, 22) (1.5,-1.5,21)

     (-1.5,-0.5, 21) (-0.5,-0.5,23)  (0.5,-0.5, 22) (1.5,-0.5,20) 

     (-1.5,0.5, 22) (-0.5,0.5,23)  (0.5,0.5, 24) (1.5,0.5,21) 

     (-1.5,1.5, 21) (-0.5,1.5,20)  (0.5,1.5, 21) (1.5,1.5,22) 
  };
  \end{axis}
 \end{tikzpicture}
\end{document}
Jake
  • 232,450
  • Oh great, I didn't know of that plot type at all. It seems this came up in pgfplots 1.13 to which I updated yesterday for a different reason. – Christoph Mar 06 '16 at 13:10