Cómo colorear una parte de la curva.

Cómo colorear una parte de la curva.

Me gustaría colorear una parte de la curva, como en la imagen. Use el siguiente código

\documentclass{article}
\usepackage{tikz,amsmath, amssymb,bm,color}
\usetikzlibrary{calc}
\usetikzlibrary{intersections}
\usetikzlibrary{shapes,arrows,arrows.meta,angles,quotes,patterns,patterns.meta}
\begin{document}
    \begin{tikzpicture}[>=stealth']
        %\tikzstyle{every node}=[font=\footnotesize]
        
        \draw[->](-0.5,1.5)--(9.5,1.5) node[right]{$u$};
        \draw[->](0,-2)--(0,4.75) node[left]{$v$};
        
        \draw [thick] plot [domain=0:2](0.5,2.5) 
        .. controls ++(60:2.5) and ++(120:1.5) .. (3.5,3.5)
        .. controls ++(-60:1) and ++(-120:1) .. (5,3.5)
        .. controls ++(60:1.5) and ++(120:1.5) .. (7,2.5)
        .. controls ++(-60:1) and ++(-160:1) .. (9,2);  
        \begin{scope}[yscale=-1,shift={(0,-3)}]
            \draw [thick] (0.5,2.5) 
            .. controls ++(60:2.5) and ++(120:1.5) .. (3.5,3.5)
            .. controls ++(-60:1) and ++(-120:1) .. (5,3.5)
            .. controls ++(60:1.5) and ++(120:1.5) .. (7,2.5)
            .. controls ++(-60:1) and ++(-160:1) .. (9,2);
        \end{scope}
    \end{tikzpicture}
\end{document}

ingrese la descripción de la imagen aquí

Respuesta1

Una opción es dibujar otra curva encima (Actualizado según el comentario de @ hpekristiansen más algo de limpieza):

\documentclass{article}
\usepackage{tikz,amsmath, amssymb,bm,color}
\usetikzlibrary{calc}
\usetikzlibrary{intersections}
\usetikzlibrary{shapes,arrows,arrows.meta,angles,quotes,patterns,patterns.meta}

\begin{document}
    \begin{tikzpicture}[>=stealth', remember picture, overlay]
       \tikzstyle{reverseclip}=[
            insert path={
                (current page.north east)
                -- (current page.south east)
                -- (current page.south west)
                -- (current page.north west)
                -- (current page.north east)
            }
        ];

        \tikzset{
            myCurve/.pic={
                .code={
                    \draw [thick] plot [domain=0:2] (0.5,2.5) 
                    .. controls ++(60:2.5) and ++(120:1.5) .. (3.5,3.5)
                    .. controls ++(-60:1) and ++(-120:1) .. (5,3.5)
                    .. controls ++(60:1.5) and ++(120:1.5) .. (7,2.5)
                    .. controls ++(-60:1) and ++(-160:1) .. (9,2);  
                }
            }
        }
        \draw[->](-0.5,1.5)--(9.5,1.5) node[right]{$u$};
        \draw[->](0,-2)--(0,4.75) node[left]{$v$};
        
        \coordinate (B) at (4,5);
        \coordinate (E) at (7,-5);
        
        \begin{scope}
            \clip[reverseclip] (B) rectangle (E);
            \path (0, 0) pic {myCurve};
        \end{scope}        
        
        \begin{scope}
            \clip (B) rectangle (E);
            \path[red] (0, 0) pic {myCurve};
        \end{scope}
    
        \begin{scope}[shift={(0,3)}]
            \path (0, 0) pic[yscale=-1] {myCurve};
        \end{scope}
    
    \end{tikzpicture}
\end{document}

ingrese la descripción de la imagen aquí

información relacionada