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):

\documentclass[11pt,twoside,a4paper]{article}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\pgfplotsset{plot coordinates/math parser=false}
\usepackage{tikz}                       %inline graphics
\usetikzlibrary{plotmarks,external}   
\begin{document}

\begin{tikzpicture}

\begin{axis}[width=\textwidth,height=4cm,axis on top,scale only axis,
xmin=0,xmax=5,xlabel={myxlabel},ymin=0,ymax=4000,
colorbar,
colormap ={mymap}{rgb(0pt)=(0,1,1); rgb(63pt)=(1,0,1)},
ylabel={myylabel}
]
\end{axis}
\end{tikzpicture}%
\end{document}

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

 
discard

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

Browse other questions tagged or ask your own question.