[Tex/LaTex] How to get color cycle list working for \draw in pgfplots

pgfplotstikz-pgf

I have the MWE with a line specified by angles and a circle specified by \draw. I am able to get the colors cycled for the other lines plotted with \addplot. However, it does not work for \draw. How to get color cycles working for lines plotted with \draw?

MWE

\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{
    compat=1.9,
    }

\begin{document}
\begin{figure}[h]
\begin{tikzpicture}
    \begin{axis}[
        axis equal,
        xlabel=x,
        ylabel=y,
        cycle list name=exotic,
        ]
        \addplot+[solid,line width=1.0pt] coordinates {(10,10) (1,1)};
        \addplot+[dotted,line width=1.0pt] coordinates {(10,1) (1,10)};
        \addplot+[loosely dotted,line width=1.0pt] coordinates {(1,1) (1,10)};
        \draw (1,1) -- ++(45:2cm) -- ++(90:3cm);
        \draw[solid,line width=1.0pt] (axis cs:5.5,5.5) circle [radius=1];
    \end{axis}
\end{tikzpicture}
\end{figure}
\end{document}

Best Answer

I'm not sure if/how you can access the current state of the cycle list and apply that in a \draw, but you could alternatively do all the parts you show with \addplot.

I show two methods for the line with relative coordinates. One (see the fourth \addplot below) is really only practical if you have few points. The other one is more flexible. You just specify the relative coordinates in a table, and the cumulative sum (i.e. the absolute coordinate) is calculated by pgfplotstable.

The circle is a simple parametric plot.

output of code

\documentclass{article}
\usepackage{pgfplotstable}
\pgfplotsset{
    compat=1.9,
    }

% read in numbers
\pgfplotstableread{
x y
1 1
2*cos(45) 2*cos(45)
0 3
}\data

% create new columns with cumulative sum
\pgfplotstablecreatecol[create col/expr={\pgfmathaccuma+\thisrow{x}}]{cumx}{\data}
\pgfplotstablecreatecol[create col/expr={\pgfmathaccuma+\thisrow{y}}]{cumy}{\data}

\begin{document}
\begin{figure}[h]
\begin{tikzpicture}
    \begin{axis}[
        axis equal,
        xlabel=x,
        ylabel=y,
        cycle list name=exotic,
        ]
        \addplot+[solid,line width=1.0pt] coordinates {(10,10) (1,1)};
        \addplot+[dotted,line width=1.0pt] coordinates {(10,1) (1,10)};
        \addplot+[loosely dotted,line width=1.0pt] coordinates {(1,1) (1,10)};
        \addplot +[mark size=5pt,ultra thick] coordinates {(1,1)({1+2*cos(45)},{1+2*sin(45)})({1+2*cos(45)},{4+2*sin(45)})};
        \addplot table[x=cumx,y=cumy] {\data};
        \addplot +[solid,line width=1.0pt,domain=0:360,samples=50,mark repeat=10] ({5.5+cos(x)},{5.5+sin(x)});
    \end{axis}
\end{tikzpicture}
\end{figure}
\end{document}