# How to shift yticklabels vertically?

When plotting data matrices as done here and here, the tick labels get drawn at the border of fields. They should be drawn in the center. I've tried shifting them using hspace and vspace. This works for the xticklabels, but not for the yticklabels.

It could be done manually by setting: yticks = {0.5} and yticklabels = {1}, but this command is called for plots of different sizes.

This seems like there should be an easy solution, but I didn't find anything in the manual.

\documentclass[a4paper,10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usepackage{pgfplots}

\begin{document}
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}},
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,
try min ticks=3,
height=1.5cm,
x=0.25cm
},
xticklabel = {\hspace{-1.5cm}$\pgfmathprintnumber\tick$},
yticklabel = {\vspace{-1.5cm}$\pgfmathprintnumber\tick$},
xtickmin = 1,
ytickmin = 1,
xtick=data,
ytick=data,
point meta min=0,
point meta max=1,
xlabel=original feature,
ylabel=recovered feature,
y label style = {rotate=90},
axis equal,
x = 1.5cm,
y = 1.5cm,
z = 0cm ]
\end{axis}
\end{tikzpicture}

\end{document}


There was in fact an easy solution: The ticklabels can be shifted by using (surprise!) xshift and yshift. Somehow this eluded me during the first read of the manual.

\documentclass[a4paper,10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usepackage{pgfplots}

\begin{document}
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}},
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,
try min ticks=3,
height=1.5cm,
x=0.25cm
},
xticklabel style = {xshift=-0.75cm},
yticklabel = {yshift=-0.75cm},
xtickmin = 1,
ytickmin = 1,
xtick=data,
ytick=data,
point meta min=0,
point meta max=1,
xlabel=original feature,
ylabel=recovered feature,
y label style = {rotate=90},
axis equal,
x = 1.5cm,
y = 1.5cm,
z = 0cm ]