It may be a bit difficult sometimes to deal with the legend of a figure in a LaTeX document. Depending on the context, you may have to place the legend over the existing curves because of a lack of space. You may also have to place it on the side making the centering of the main content difficult. Some people choose to put the legend in the caption thus discarding the above mentioned difficulties. Below is a solution with pstricks:
\documentclass[dvips,11pt,fleqn]{article}
\usepackage{lmodern}
\usepackage{xcolor}
\usepackage{graphicx}
\usepackage{pstricks-add}
\usepackage[top=2cm,bottom=2cm,left=2cm,right=2cm,a4paper]{geometry}
\newbox{\LegendeA}
\savebox{\LegendeA}{
(\begin{pspicture}(0,0)(0.6,0)
\psline[linewidth=0.04,linecolor=red](0,0.1)(0.6,0.1)
\end{pspicture})}
\newbox{\LegendeB}
\savebox{\LegendeB}{
(\begin{pspicture}(0,0)(0.6,0)
\psline[linestyle=dashed,dash=1pt 2pt,linewidth=0.04,linecolor=blue](0,0.1)(0.6,0.1)
\end{pspicture})}
\begin{document}
\begin{figure}[h]
\centering
\begin{pspicture*}[showgrid=true](0,-2.5)(7,2.5)
\psframe[fillstyle=solid,fillcolor=gray!10](-1,-3)(8,3)
\psplot[linewidth=1.5pt,algebraic=true,linecolor=red]
{0}{7}{sqrt(x)*cos(x)*sin(x)}
\psplot[linewidth=1.5pt,algebraic=true,linecolor=blue,linestyle=dashed,dash=1pt 2pt]
{0}{7}{sqrt(x)*cos(x)}
\end{pspicture*}
\caption{Vibrations of the structure; wheel~\usebox{\LegendeA} and
piston~\usebox{\LegendeB}}
\end{figure}
\end{document}

What are your strategies?

