I have figured out how to define my own colormap in pgfplots
. My understanding is that when I define my color map and I plot any graph that requires a colorbar, the default coloring scheme used becomes the one that I have defined. My question is, what if I am defining multiple colormaps, how do I specify the one I want to pick? I couldn't really find the options. Here is a MWE
\documentclass{article}
\usepackage{pgfplots}
\usepackage{tikz}
\pgfplotsset{
colormap={mygreen}{rgb255(0cm)=(0,0,0); rgb255(1cm)=(0,255,0)}
}
\begin{document}
\begin{figure}
\begin{tikzpicture}[scale=0.45]
\begin{axis}[view={0}{90},colorbar]
\addplot3[surf, shader=interp] table{
1 0 2
2 0 1
1 1 0
2 1 3
1 2 1
2 2 1
};
\end{axis}
\end{tikzpicture}
\end{figure}
\end{document}
The above example will use mygreen
colormap. Say for example I have defined another colormap colormap={randcolor}{rgb255(0cm)=(0,100,0); rgb255(1cm)=(100,255,155)}
, how would I choose to use that one? At first I used the option colormap/mygreen
, but it was giving me some compilation errors.
Best Answer
The option for this is called
colormap name
and can be set to your axis. Please see my example below: