# Pgfplots: Limit y-axis and colorbar to external graphics height

I use ParaView for the creation of plots. My example picture has a resolution of 2688x1635 pixel, so roughly an aspect ratio of 1.64. Using pgfplots I want to include the picture while preserving the aspect ratio and add a colorbar to the picture. I was able to do that:

However, I have no luck limiting the y-axis and therefore the colorbar height to the actual y-dimensions of the included picture. I tried using ymin=0 and ymax=1 in the axis definition and y domain=0:1 for the data but nothing works.

How can I get rid of the additional white space for y<0 and y>1?

\documentclass{standalone}

\usepackage{pgfplots}
\pgfplotsset{compat=1.12}

\begin{document}

\begin{tikzpicture}
\begin{axis}[
%     hide axis,
width=0.6\linewidth,
scale only axis,
enlargelimits=false,
axis equal=true,
colormap/bluered,
colorbar,
colorbar sampled,
colorbar style={separate axis lines, samples=16},
]
\addplot [point meta min=0, point meta max=1.0] graphics [xmin=0.0,xmax=1.64,ymin=0.0,ymax=1.0]{example-image-a};
\end{axis}
\end{tikzpicture}

\end{document}

• Ok, sometimes thinking helps. Using axis equal image instead of axis equal=true solves the problem. – raedma Mar 4 '16 at 12:18

Using axis equal image instead of axis equal=true solves the problem:

\documentclass{standalone}

\usepackage{pgfplots}
\pgfplotsset{compat=1.12}

\begin{document}

\begin{tikzpicture}
\begin{axis}[
width=0.6\linewidth,
scale only axis,
enlargelimits=false,
%axis equal=true,
axis equal image,
colormap/bluered,
colorbar,
colorbar sampled,
colorbar style={separate axis lines, samples=16},
]
\addplot [point meta min=0, point meta max=2.0] graphics [xmin=0.0,xmax=1.64,ymin=0.0,ymax=1.0]{example-image-a};
\end{axis}
\end{tikzpicture}

\end{document}