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'd like to replicate this colormap in TiKz or pgfplots. Let me clarify, I don't need a plot of any kind, these are screen-shots from another application. But since the labels on the pic below are poor I'd like to make it more professional.

enter image description here

So far I have this rubbish:

enter image description here

Is there a way to cut out the adjoining plot altogether and put my own tick labels on the contour?

\documentclass[tikz,border={12pt,12pt}]{standalone}
\usepackage{pgfplots}
\usetikzlibrary{plotmarks}
\pgfplotsset{compat=newest}
\begin{document}
\begin{tikzpicture}

 \begin{axis}[hide axis,colorbar,colormap/jet,
  colorbar style={yshift=-2cm,
    xtick={18,22,26,30,34,38,42,45},
    xticklabel={18,22,26,30,34,38,42,45},
    rotate=270,
    yticklabel pos=left,
    yticklabel style={anchor=south},},
    ]
   { 
  };
 \end{axis}
\end{tikzpicture}

\end{document}
share|improve this question

1 Answer 1

up vote 10 down vote accepted

You can make the axis take up no space by setting scale only axis, width=0pt, height=0pt, hide axis.

To be able to set the range of the colorbar, you have to provide a dummy plot. Then you can set point meta min and point meta max to control the range:

\documentclass{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
    hide axis,
    scale only axis,
    height=0pt,
    width=0pt,
    colormap/jet,
    colorbar horizontal,
    point meta min=18,
    point meta max=45,
    colorbar style={
        width=10cm,
        xtick={18,20,25,...,45}
    }]
    \addplot [draw=none] coordinates {(0,0)};
\end{axis}
\end{tikzpicture}

\end{document}
share|improve this answer
1  
Fantastic! Thank you very much Jake! Is it possible to make the colours discrete? –  HCAI Jun 20 '13 at 11:37
1  
@HCAI: Sure. Just set colorbar sampled before colorbar horizontal, and then set samples=<number> in the colorbar style. –  Jake Jun 20 '13 at 11:45
    
Super! One other question, since the the colorbar is an axis in its own right, can you change its size without adding more gradations? –  HCAI Jun 20 '13 at 11:47
    
@HCAI: You can change the width in the colorbar style options. That doesn't affect the number of samples. Is that what you mean? –  Jake Jun 20 '13 at 14:22

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.