I'm trying to plot a data matrix using pgfplots and a surface plot.
The method described in this question worked well for me: Using pgfplots, how do I arrange my data matrix for a surface plot so that each cell in the matrix is plotted as a square?
Each square should be quadratic, so I tried to set the sizes by using "x = 1cm, y = 1cm", as described in this answer: https://tex.stackexchange.com/a/31028/29619
Unfortunately, this results in a mangled plot and a warning.
This code compiles to a flat plot with non-square rectangles:
\documentclass[a4paper,10pt]{article}
\usepackage{tikz}
\usepackage{pgfplots}
\usepackage{pgfplotstable}
\begin{document}
\pgfplotstableread{
0 0 0.77
0 1 0
1 0 0
1 1 0
}\data
\begin{tikzpicture}
\begin{axis}[
width=5cm,
title={\texttt{Minimal purity plot}},
view={0}{90},
colormap={bluenew}{rgb255(0cm)=(255,255,255); rgb255(1cm)=(40,40,240)},
colorbar,
colorbar style={
at={(1.5, 0.5)},
anchor=west,
xticklabel pos=right,
},
xmin=0,
xmax=1,
ymin=0,
ymax=1,
xtick=data,
ytick=data,
point meta min=0,
point meta max=1,
xlabel=x,
ylabel=y]
\addplot3 [surf, shader=flat corner] table {\data};
\end{axis}
\end{tikzpicture}
\end{document}
When I add "x = 1cm, y = 1cm" to the axis settings, a warning occurs about a missing size for set. If I add "z = 1cm" as well, it looks like a 3D-box again.
It ought to look like in the MWE, but with different sizes. Is there a way to do this?
Changing the width in the axis description did not help.
EDIT Thanks to percusse's suggestion, the cells are now squares. I'd still like to have different plots with consistent cell sizes accross plots.
\pgfplotstableread{
0 0 0.77
0 1 0.5
0 2 0
1 0 0
1 1 0.3
1 2 0
2 0 0.9
2 1 0
2 2 0
}\datan
\begin{tikzpicture}
\begin{axis}[
title={\texttt{Second working plot}},
view={0}{90},
colormap={bluenew}{rgb255(0cm)=(255,255,255); rgb255(1cm)=(40,40,240)},
colorbar,
colorbar style={
at={(1.5, 0.5)},
anchor=west,
xticklabel pos=right,
},
xmin=0,
xmax=2,
ymin=0,
ymax=2,
xtick=data,
ytick=data,
point meta min=0,
point meta max=1,
xlabel=x,
ylabel=y,
axis equal]
\addplot3 [surf, shader=flat corner] table {\datan};
\end{axis}
\end{tikzpicture}
In this second example, the cells are much smaller, since more of them are fitted in the same plot. I'd like the cell sizes to be consistent and the plot size to change instead.

axis equal? – percusse Aug 05 '13 at 13:30axis equalhelps in making the fields quadratic. I'd still like to set them to a specific size for better comparability between plots. – mektah Aug 05 '13 at 13:35