As the title says, I want to make a vertical colorbar showing the Kelvin temperature on a logarithmic scale, with the regular ticks on the right side, and some custom ticks on the left (i.e. absolute 0 at the bottom, melting point of ice at 273).

I've got the basic colorbar working, but the ticks are going from 1 to -1 instead of 10^9 to -10^9. I also don't know how to add custom ticks to the other side.




  \begin{axis}[scale only axis, hide axis, height=0em, width=0em, colormap/jet,
    colorbar horizontal, point meta min=-1000000000, point meta max=1000000000,
    colorbar style={width=.8\textheight, rotate=90, % xtick={1000000000,100000000,...,-1000000000}, % This gives me 'Dimesion too large' errors
    \addplot [draw=none] coordinates {(0,0)};

<code>enter image description here</code>


1 Answer 1


I admit that I have a couple of questions which may indicate that I did not understand/think through your question (for example, how to you want to display -1*10^9 on a log scale? Or do you mean 10^-9? Do you really mean a log scale or do you merely want "large numbers"? Why do you use colorbar horizontal with a rotation of 90?). Anyway, I tend to not think through these questions and give you some hints which will (hopefully) help you to figure out the rest for yourself:




    scale only axis,
    hide axis, 
    point meta min=-1000000000, point meta max=1000000000,
    colorbar style={
        scaled ticks=false,
        extra y ticks={-1e9,1e9},
        extra y tick labels={$0$,Warm},
        extra y tick style={
            yticklabel pos=left,

enter image description here

  1. Use ymode=log if you want a logarithmic axis. This won't affect the shading, it merely affects how labels are drawn on top of it. Note that this does not work for negative values (naturally), you would also need to adopt point meta min.

  2. ytick still uses PGF natively which, unfortunately, does not support large numbers. This is a weakness in pgfplots which will be addressed eventually. For now, you have to expand the "..." manually for large numbers.

  3. Your image does not show -1 ... 1; it shows -1 *10^9 ... +1 *10^9 (see the small tick scale label at the bottom. Use scaled ticks=false to disable tick scaling.

  4. Extra ticks can be added using extra y ticks and its variants. The example should give you some pointers into the documentation.

  5. Consider using \pgfplotsset{compat=1.12} or newer in the preamble. In this case, it reduces the bounding box of the figure. This key is generally a good practise.

  • Thanks, I realized that I had the lower bound wrong, and after correcting that and enabling the log scale I got exactly what I wanted :)
    – JamesNZ
    Sep 12, 2015 at 5:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .