The \extractcolorspec
macro will define a macro that contains the specification for a color; we can use it and the companion \convertcolorspec
to define a macro containing the specifications for another model:
\definecolor{canvascolor}{rgb}{0.643,0.690,0.843}
\extractcolorspec{canvascolor!75!white}{\test}
\expandafter\convertcolorspec\test{HTML}\test
Now \test
will expand to BBC4E1
.
The first definition of \test
will be {rgb}{0.73225,0.7675,0.88225}
so this is good for putting it after \convertcolorspec
, but we have to expand it first.
Use two different macros if you also need to keep the first specification around.
We can implement this in a function
\newcommand{\getColorSpec}[3][\getColorSpecTemp]{%
\extractcolorspec{#3}\getColorSpecTemp
\expandafter\convertcolorspec\getColorSpecTemp{#2}#1}
With \getColorSpec{HTML}{canvascolor!75!white}
the specification will be stored in \getColorSpecTemp
; with
\getColorSpec[\HTMLcolor]{HTML}{canvascolor!75!white}
the same specification will be stored in \HTMLcolor
.
You can make a colour from the colormap available as mapped color
by calling the macro \pgfplotscolormapdefinemappedcolor{<value>}
, where <value>
is a number between 0 and 1000 that is mapped linearly into the current color map.
In order to use different colours for different plots, this macro needs to be called within execute at begin plot visualization
, otherwise all the plots end up with the same colour:
\documentclass[border=1mm]{standalone}
\usepackage{pgfplots}
%\usepgfplotslibrary{colormaps}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
colormap/hot,
domain=0:360,
colorbar sampled,
colorbar style={samples=6},
point meta min=0,
point meta max=10
]
\pgfplotsinvokeforeach{1,...,5}{
\addplot [
execute at begin plot visualization={%
\pgfplotscolormapdefinemappedcolor{\numexpr#1*200-100\relax}
},
mapped color,
thick
] {#1*sin(x)};
}
\end{axis}
\end{tikzpicture}
\end{document}
Best Answer
You can let xcolor show you the numbers: