[Tex/LaTex] How to use colors from a pgfplots colormap in own draw


Let's consider a set of ellipses (or say a signal), here 3, but in general that might be a huge array of 64x64



            \draw[rotate around={-20:(0,0)},black] (0,0) ellipse (.5 and .25);
            \draw[rotate around={0:(1,0)},black] (1,0) ellipse (.45 and .3);
            \draw[rotate around={20:(2,0)},black] (2,0) ellipse (.4 and .35);

And I further have values from 0 to 1 for each ellipse indicating a color, that is i would like to replace the black by some color from a colormap, maybe the /pgfplots/colormaps/hue colormap. Let these values for example be

 {0.2, 0.6, 0.3}

The I would like to read the colormap values at these points and use them to fill (or draw) the ellipses.

So for short the question is: How can I access a specific color in a pgfplots-colormap?

Best Answer

As with the release of PGFPlots v1.13 you can use the new keys color of colormap or index of colormap to get easy access to the colors of the colormap. See section 4.7.6 pages 192f in the manual.

Here your code again using the first mentioned feature

            color of colormap={#1},
            hide axis,
            xmin=-2.5, xmax=2.5,
            ymin=-.5, ymax=.5,
            axis equal,
            \draw[ellC=200, rotate around={-20:(0,0)}] (0,0) ellipse (.5  and .25);
            \draw[ellC=600, rotate around={0:(1,0)}]   (1,0) ellipse (.45 and .3);
            \draw[ellC=300, rotate around={20:(2,0)}]  (2,0) ellipse (.4  and .35);

image of the result of above code