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 small problem with TikZ I can't figure out. I have some TikZ code generated in MATLAB (using matlab2tikz) showing an image with a user-defined colormap and the correspondent colorbar. The image is exported as .png but given that the colorbar is created in TikZ I need to color it accordingly (defining the new colormap). I simplified the code to get a MWE and it reads as follows (I replaced the user-defined colormap with a simple one):

\pgfplotsset{plot coordinates/math parser=false}
\usepackage{tikz}                       %inline graphics


\begin{axis}[width=\textwidth,height=4cm,axis on top,scale only axis,
colormap ={mymap}{rgb(0pt)=(0,1,1); rgb(63pt)=(1,0,1)},

This works fine, but given that my colormap has more than two colors definitions, I thought that saving it in a separate .tex file, say mycmap.tex, was a nice idea

colormap ={mymap}{\input{mycmap}},

However, if I do this it doesn't work... I tried to save it as a .txt file instead of .tex, but still no luck. Any idea on how to fix it?

Thanks in advance! ;)

share|improve this question

Your Answer


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

Browse other questions tagged or ask your own question.