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 have a 3d plot with colored surface and a colorbar made with pgfplots.

My probably related questions are:

How can I set the label of the colorbar? What are the equivalents of zticks (positions of its ticks), and ztick label style (changing the format of the numbers)?

Thank you very much!

share|improve this question
1  
It's usually a good idea to post a small complete example document. That helps to clarify the question, and it saves others the work of having to come up with a test case. –  Jake Sep 18 '12 at 12:23
add comment

1 Answer

up vote 13 down vote accepted

The colour bar is a full-fledged axis environment, so all the usual options are available (like title). The ticks in this case are y ticks, so you can set the axis label using ylabel and the tick label style using yticklabel style:

\documentclass[border=5mm]{standalone}

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

\begin{document}
\begin{tikzpicture}
\begin{axis}[
    domain=-180:180,
    colorbar,
    colorbar style={
        title=Color key,
        ylabel=Z-value,
        ytick={-1,-0.75,...,1},
        yticklabel style={
            text width=2.5em,
            align=right,
            /pgf/number format/.cd,
                fixed,
                fixed zerofill
        }
    }
]
\addplot3 [surf] {sin(x) * sin(y)};
\end{axis}
\end{tikzpicture}
\end{document}
share|improve this answer
    
+1, in my case this resulted in an error Dimensions too large. But setting xtick={150,200,250,300} worked. –  Sebastian Mar 15 '13 at 13:41
add comment

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.