# Changing Color in Coordinate Plot in Tikz

I want to change the color in alternates of red and blue. So far I only have:

 \documentclass{article}
\usepackage{tikz}

\begin{document}
\begin{center}
\begin{tikzpicture}[scale=.8]
% Axes
\draw [-latex] (-1,0) -- (12,0) node (xaxis) [right] {$x$};
\draw [-latex] (0,-1) -- (0,6.5) node [above] {$y$};
% Origin
\node at (0,0) [below left] {$0$};
% Points
\coordinate (start) at (1,1.5);
\coordinate (1) at (3,.5);
\coordinate (2) at (5.5,4.5);
\coordinate (3) at (7.5,2.75);
\coordinate (end) at (9,6);
% Plot
\draw [red,thick,-] (start) to[out=-30,in=180] (1) to[out=0,in=180]
(2) to[out=0,in=110] (3) to[out=45,in=225] (end);

% show the points

\foreach \n in {start,1,2,3,end} \fill [black] (\n)
circle (2pt) node [below] {};

\end{tikzpicture}
\end{center}
\end{document}


This outputs:

Any advice how to make the color alternative between red and blue with one color between each point?

Some improvements in the code.

• standalone class to produce a single draw.
• You can scope the lines to set the line width once.
• You don't need to insert node in the bullets.
• black is the default color, don't need to pass it to fill.

\documentclass[tikz,margin=2mm]{standalone}

\begin{document}
\begin{tikzpicture}
% Axes
\draw [-latex] (-1,0) -- (12,0) node (xaxis) [below] {$x$};
\draw [-latex] (0,-1) -- (0,6.5) node [left] {$y$};

% Origin
\node at (0,0) [below left] {$0$};

% Points
\coordinate (start) at (1,1.5);
\coordinate (1) at (3,.5);
\coordinate (2) at (5.5,4.5);
\coordinate (3) at (7.5,2.75);
\coordinate (end) at (9,6);

% Plot
\begin{scope}[thick]
\draw [red]         (start) to[out=-30,in=180] (1);
\draw [red!60!blue] (1)     to[out=0,in=180]   (2);
\draw [red!30!blue] (2)     to[out=0,in=110]   (3);
\draw [blue]        (3)     to[out=45,in=225]  (end);
\end{scope}

% show the points
\foreach \n in {start,1,2,3,end}{%
\fill (\n) circle (2pt);
}
\end{tikzpicture}
\end{document}

• you broke it up in parts and then redefined the color. Thanks, for some reason I kept thinking that it wasn't possible. – MathScholar Dec 27 '18 at 15:44
• @MathScholar, welcomed. – Sigur Dec 27 '18 at 15:49