[Tex/LaTex] Color-bar – surf plot

pgfplotstikz-pgf

I have a surf plot as shown below. enter image description here However, the markings on the color-bar are in steps of 0.05. Instead, I want the markings to be in steps of 0.25. How should I go about doing this? Below is the code, which produces the surf plot shown above.

\begin{tikzpicture}[scale=0.15]
\pgfplotsset{compat=newest}
\tikzstyle{every node}=[font=\Huge]
every mark/.append style={rotate=90}.
\begin{axis}[
colorbar,
view={60}{30},
smooth,
mark size = 1.5,
xmin=16, xmax=24,
ymin=1650, ymax=1675,
zmin=0.25, zmax=2.25,
xtick = {16,18,20,22},
ytick = {1650,1655,1660,1665,1670,1675},
ztick = {0.25,0.5,0.75,1,1.25,1.5,1.75,2,2.25},
xlabel= $a$,
ylabel= $b$,
zlabel= Relative error,
xlabel style = {sloped like x axis},
ylabel style = {sloped like y axis},
]
\addplot3[surf,mesh/rows=5,shader=interp] coordinates {
(16,1650,1.6148) (18,1650,1.6283) (20,1650,1.6421) (22,1650,1.6449) (24,1650,1.6579)
(16,1655,1.5114) (18,1655,1.5058) (20,1655,1.4948) (22,1655,1.4738) (24,1655,1.4474)
(16,1660,1.2262) (18,1660,1.2302) (20,1660,1.2280) (22,1660,1.2320) (24,1660,1.2283)
(16,1665,0.3534) (18,1665,0.3103) (20,1665,0.3159) (22,1665,0.3312) (24,1665,0.3621)
(16,1675,2.0557) (18,1675,1.0734) (20,1675,1.0279) (22,1675,0.9771) (24,1675,0.9127)
};
\end{axis}
\end{tikzpicture}

Best Answer

You can use colorbar style={ ytick={0.50, 0.75, ..., 2.00} } to chose the tick labels for the color bars:

enter image description here

Notes:

  • I am not sure if there is something wrong with my installation, but I had to remove your scale and \tikzstyle settings on my Mac to obtain a decent image. On my PC version, I did not need to do that -- but based on my previous problems I thought that the Mac installation is ok, and the PC installation is corrupt> But the PC installation produced results identical to your, so I don't know.

Code:

\documentclass{article}
\usepackage{pgfplots}

\pgfplotsset{compat=newest}

\begin{document}
\begin{tikzpicture}
%\tikzstyle{every node}=[font=\Huge]
%every mark/.append style={rotate=90}.
\begin{axis}[
colorbar, colorbar style={ ytick={0.50, 0.75, ..., 2.00} },
view={60}{30},
smooth,
mark size = 1.5,
xmin=16, xmax=24,
ymin=1650, ymax=1675,
zmin=0.25, zmax=2.25,
xtick = {16,18,20,22},
ytick = {1650,1655,1660,1665,1670,1675},
ztick = {0.25,0.5,0.75,1,1.25,1.5,1.75,2,2.25},
xlabel= $a$,
ylabel= $b$,
zlabel= Relative error,
xlabel style = {sloped like x axis},
ylabel style = {sloped like y axis},
]
\addplot3[surf,mesh/rows=5,shader=interp] coordinates {
(16,1650,1.6148) (18,1650,1.6283) (20,1650,1.6421) (22,1650,1.6449) (24,1650,1.6579)
(16,1655,1.5114) (18,1655,1.5058) (20,1655,1.4948) (22,1655,1.4738) (24,1655,1.4474)
(16,1660,1.2262) (18,1660,1.2302) (20,1660,1.2280) (22,1660,1.2320) (24,1660,1.2283)
(16,1665,0.3534) (18,1665,0.3103) (20,1665,0.3159) (22,1665,0.3312) (24,1665,0.3621)
(16,1675,2.0557) (18,1675,1.0734) (20,1675,1.0279) (22,1675,0.9771) (24,1675,0.9127)
};
\end{axis}
\end{tikzpicture}
\end{document}