4

I need to create a graph such as this one:

enter image description here

I don't know how to create the red line that you see in case 1 so that it will cross the blue line more than once.

Here is what I got so far.

\documentclass[]{standalone}

\usepackage{tikz} % To plot almost everything.
\usetikzlibrary{arrows,calc, patterns, positioning, shapes.geometric, decorations.pathreplacing,decorations.markings}
\usepackage{graphicx}
\usepackage{rotating}
\usepackage{textcomp}

\begin{document}

\begin{tikzpicture}[scale=0.8]
\scriptsize

\draw (0,0) -- (3.3,0);
\draw (0,-0.75) -- (0,3);
\node [right] at (3.3,0) {$m$};
\node [left] at (0,3) {};
\draw [blue] (0.05,2.75) to [out=270,in=180] (3.2,-0.2);
\draw [fill] (0.155,2) circle [radius =0.05];
\draw [fill] (0.52,1.2) circle [radius =0.05];
\draw [fill] (1.1,0.55) circle [radius =0.05];
\draw [fill] (1.8,0.11) circle [radius =0.05];
\node [below] at (1.9,-1) {\small Case 1};

\draw [xshift=5.1cm] (0,0) -- (3.3,0);
\draw [xshift=5.1cm] (0,-0.75) -- (0,3);
\node [xshift=4.1cm][right] at (3.3,0) {$m$};
\draw [xshift=5.1cm,blue] (0,1.8) to [out=290,in=180] (3.1,0.05);
\node [xshift=4.2cm,blue,above] at (3.1,0.0) {$u_2$};
\draw [xshift=5.1cm,red] (0,2.83) to [out=290,in=182] (3.1,0.55);
\node [xshift=4.2cm,red,above] at (3.1,0.5) {$\gamma u_1$};
\node [xshift=4.1cm, below] at (1.9,-1) {\small Case 2};

\draw [xshift=10.2cm] (0,0) -- (3.3,0);
\draw [xshift=10.2cm] (0,-0.75) -- (0,3);
\draw [xshift=10.2cm,red] (0,1) -- (3,1);
\node [xshift=8.2cm,red] at (3.3,1) {$\gamma u_1$};
\draw [xshift=10.2cm,blue] (0,2.5) to [out=290,in=170] (3.1,0.15);
\node [xshift=8.2cm,blue,above] at (3.1,0.15) {$u_2$};
\draw [xshift=10.2cm,fill] (1.03,1) circle [radius =0.05];
\node [xshift=8.2cm][right] at (3.3,0) {$m$};
\node [xshift=8.2cm,below] at (1.9,-1) {\small Case 3};

\end{tikzpicture}
\end{document}

enter image description here

2 Answers 2

1

You are already specifying the points at which the red curve is to intersect with the blue one. So you could simply use them in a curve.

enter image description here

\documentclass[tikz,border=3.14pt]{standalone}

\begin{document}

\begin{tikzpicture}[scale=0.8]
\scriptsize

\draw (0,0) -- (3.3,0);
\draw (0,-0.75) -- (0,3);
\node [right] at (3.3,0) {$m$};
\node [left] at (0,3) {};
\draw [blue] (0.05,2.75) to [out=270,in=180] (3.2,-0.2);
\draw [fill] (0.155,2) circle [radius =0.05];
\draw [fill] (0.52,1.2) circle [radius =0.05];
\draw [fill] (1.1,0.55) circle [radius =0.05];
\draw [fill] (1.8,0.11) circle [radius =0.05];
\draw [red] (0.05,2.75) to [out=270,in=180] (0.155,2)
to[out=0,in=90] (0.52,1.2) to[out=-90,in=180] (1.1,0.55) to[out=0,in=90] 
(1.8,0.11) to[out=-90,in=180] (3.2,-0.2);
\node [below] at (1.9,-1) {\small Case 1};

\draw [xshift=5.1cm] (0,0) -- (3.3,0);
\draw [xshift=5.1cm] (0,-0.75) -- (0,3);
\node [xshift=4.1cm][right] at (3.3,0) {$m$};
\draw [xshift=5.1cm,blue] (0,1.8) to [out=290,in=180] (3.1,0.05);
\node [xshift=4.2cm,blue,above] at (3.1,0.0) {$u_2$};
\draw [xshift=5.1cm,red] (0,2.83) to [out=290,in=182] (3.1,0.55);
\node [xshift=4.2cm,red,above] at (3.1,0.5) {$\gamma u_1$};
\node [xshift=4.1cm, below] at (1.9,-1) {\small Case 2};

\draw [xshift=10.2cm] (0,0) -- (3.3,0);
\draw [xshift=10.2cm] (0,-0.75) -- (0,3);
\draw [xshift=10.2cm,red] (0,1) -- (3,1);
\node [xshift=8.2cm,red] at (3.3,1) {$\gamma u_1$};
\draw [xshift=10.2cm,blue] (0,2.5) to [out=290,in=170] (3.1,0.15);
\node [xshift=8.2cm,blue,above] at (3.1,0.15) {$u_2$};
\draw [xshift=10.2cm,fill] (1.03,1) circle [radius =0.05];
\node [xshift=8.2cm][right] at (3.3,0) {$m$};
\node [xshift=8.2cm,below] at (1.9,-1) {\small Case 3};

\end{tikzpicture}
\end{document}

I also removed all unnecessary packages and TikZ libraries. And I am wondering about two things. First, you are using xshift very much. Personally I'd use scopes. Second, how did you get those points on the first curve? It might be much easier to get them with decorations.markings.

1
  • With respect to your questions, about xshif I must admit I am just inheriting an old template that I never questioned, I will, however, take into account your suggestion. Also, the points were assigned randomly, so they could be anywhere. If you could give me more info regarding decorations.markings I would appreciate. Commented Apr 17, 2018 at 16:30
4

You can use a plot with explicit formula and place a bit of sine on it. Thenyou can use intersections library to find the crossings.

\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}
\draw (0,0) -- (3.3,0);
\draw (0,-0.75) -- (0,3);
\node [right] at (3.3,0) {$m$};
\node [left] at (0,3) {};
\draw [red, thick] plot[domain=0.:2.5, samples=41] (\x,{-0.2+2*exp(-1.5*\x)});
\draw [blue] plot[domain=0.:2.5, samples=101] (\x,{-0.2+2*exp(-1.5*\x+0.2*sin(10*\x r)});
\end{tikzpicture}
\end{document}

enter image description here

I would use pgfplots instead for these diagrams.

1
  • I need two things that this code does not provide. First, the blue line must be non-increasing. Second, it can never cross the X-axis, as in the graph. I don't know whether this is possible to do just with the sin function. Commented Apr 16, 2018 at 10:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .