Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am trying to create a 3D plot with custom z-ticks. However I can not create them with starting negative number. It works however as expected when the ticks start at 0.

My code is this one

\begin{tikzpicture}
\begin{axis}[view={30}{30},grid=major,
   /pgfplots/xtick={0,60,...,300},
   /pgfplots/ytick={0,60,...,300},
   /pgfplots/ztick={-1.0,0.2,...,1.0},
]
\addplot3[surf,domain=0:360,samples=40,
  colormap/jet,colorbar]
  {sin(x)*sin(y)};
\end{axis}
\end{tikzpicture}

with these results (the second with ztick={0,0.2,...,1.0}): enter image description here

enter image description here

How do I get correct z-ticks from -1 to 1 with steps 0.2?

share|improve this question
2  
within the axis environment the extra /pgfplots should not be needed –  Martin H Nov 24 '11 at 14:07

1 Answer 1

up vote 12 down vote accepted

The second number does not give the step size, but the next step. So try {-1.0,-0.8,...,1.0}, or, better, {-1.0,-0.8,...,-0.2,0.0,0.2,...,1.0} as in:

\documentclass{standalone}
\usepackage{tikz}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[view={30}{30},grid=major,
   /pgfplots/xtick={0,60,...,300},
   /pgfplots/ytick={0,60,...,300},
   /pgfplots/ztick={-1.0,-0.8,...,-0.2,0.0,0.2,...,1.0},
]
\addplot3[surf,domain=0:360,samples=40,
  colormap/jet,colorbar]
  {sin(x)*sin(y)};
\end{axis}
\end{tikzpicture}
\end{document}

I explicitly specified ...,-0.2,0.0,0.2,... because otherwise, you might get a tick of 10^{-5} instead of 0.

result

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.