2

I am doing a lineplot with pgfplots. However, instead of the usual legend, I would prefer a colorbar, as I am basically trying to visualize a transition, and for that I chose colors in a gradient like fashion.

How can I add a colorbar below the following MWE plot with clear steps and one label on the left and one label on the right of the colorbar to indicate that my transition is from A to B:

\documentclass{article}
\usepackage[dvipsnames]{xcolor}
\usepackage{tikz,pgfplots}

\pgfplotscreateplotcyclelist{TheBlues}{%
    {color=RoyalBlue!50!black},
    {color=RoyalBlue!70!black},
    {color=RoyalBlue!90!black},
    {color=RoyalBlue!90!white},
    {color=RoyalBlue!70!white},
    {color=RoyalBlue!50!white},
}

\pgfplotsset{cycle list name=TheBlues}

\begin{document}
    \begin{tikzpicture}
        \begin{axis}[
            xmin=0,
            xmax=1,
            axis line style={
                very thick, 
                gray,
                shorten <=-0.5\pgflinewidth
            },
            tick label style ={gray},
            axis lines*=left,
        ]
            \foreach \n in {1,2,...,6}
                \addplot+[ultra thick,smooth,domain={0:1}] {x^\n};
        \end{axis}
    \end{tikzpicture}
\end{document}
NOhs
  • 858
  • If you are willing to use other colours than your TheBlues (you could define a colormap={TheBlues} of course) you might be interested in this answer of me: http://tex.stackexchange.com/a/232697 – LaRiFaRi Aug 05 '15 at 12:24
  • That looks like what I am looking for. So it is probably a duplicate question? – NOhs Aug 05 '15 at 12:27
  • depends. If you want to use the colours your are using right now, it will get more difficult. You have to decide: If you like my approach, you may (upvote it and) close here. If you think, your TheBlues is mandatory here, you might try to define your own colormap for example. You can become more specific in the question above then. – LaRiFaRi Aug 05 '15 at 12:31
  • 1
    I was able to modify your example to suit all my needs, so I guess this is a duplicate question which can be closed. I also upvoted your answer. – NOhs Aug 05 '15 at 12:46

0 Answers0