drawing different parts of a line in different colours

How to draw different parts of a line in different colours. In the following code can each part of the line be drawn in different colour

    \documentclass{beamer}
\usepackage{tikz}
\usepackage{pgfplots}
\begin{document}
\begin{frame}[fragile,t]
\frametitle{}
{
\begin{tikzpicture}
\draw [thick, green] (2.3,1.4) +(-27:2.2cm)-- +(153:2.2cm) +(42:1.88cm) -- +(-138:1.88cm);
\end{tikzpicture}
}
\end{frame}
\end{document}

• Could you please specify how you would like the output to be? – zyy Jun 25 '18 at 18:25

Using edge could perhaps be an option.

\documentclass{beamer}