3

Trying to illustrate the fixed point of a system consisting of a linear DE and a non linear DE

I am new to latex, and I have been going through so many curves on this forum for days. I have manged to draw the curves, but labeling is now a huge mission. This is just supposed to show the intercepts and the parametric values at fixed points. Not to scale.

BELOW IS A COCKTAIL OF CODE WHICH I GOT FROM HERE TO GET THE GRAPHS:

\documentclass[tikz,border={15mm 15mm 15mm 15mm},]{standalone}
\usepackage{pgfplots} 
\pgfplotsset{compat=newest}
\pgfplotsset{plot coordinates/math parser=false}
\pgfplotsset{
    every non boxed x axis/.style={
        xtick align=center,
        enlarge x limits=true,
        x axis line style={line width=0.8pt, -latex}
},
    every boxed x axis/.style={}, enlargelimits=false
}
\pgfplotsset{
    every non boxed y axis/.style={
        ytick align=center,
        enlarge y limits=true,
        y axis line style={line width=0.8pt, -latex}
},
    every boxed y axis/.style={}, enlargelimits=false
}
\usetikzlibrary{
   arrows.meta,
  intersections,
}


\usetikzlibrary{calc}
%\pgfplotsset{compat=newest}
\usetikzlibrary{
   arrows.meta,
  intersections,}
% arrows as stealth fighters
\tikzset{>=stealth}
\begin{document}

\begin{tikzpicture}
    \begin{axis}[
            axis lines=middle,
            axis line style=<->,
            xmin=-5,xmax=8,
            ymin=-5,ymax=8,
            xlabel=$N_A$,
            ylabel=$N_B$,
            xtick=\empty,
            ytick=\empty,
            xticklabels=\empty,
            yticklabels=\empty,
        ]%\addplot[thick,domain=0:7,blue,name path = A]  {x } coordinate[pos=0.4] (m) ;
        \addplot[thick,domain=-5:7,blue,name path = A]  ({0.5* x^2-2},{x}) coordinate[pos=0.4] (m) ;
          \addplot[thick,domain=-5:7,blue,name path = B]  ({ x+2},{x}) coordinate[pos=0.4] (n) ;
         % \draw[densely dashed, name path=D] (0,4) -|node[pos=0.15, color=black, label=below:$\lambda x_{1}+ (1-\lambda)x_{2}$] {} node[pos=-2, fill,circle,inner sep=1pt] {}(m);
        %\addplot[smooth,thick, blue,-]({x^2-2},{x});
        %\addplot[smooth,thick, red,-]({x+1},{x});
       % \coordinate (Ux) at (\x,{(\x)});
       \path [name intersections={of=A and B, by={a}}] node[fill,circle,inner sep=1pt] at (a) {}; 
        \draw[densely dashed, name path=c ] (0,0) -|node[pos=0.6, color=black, label=below:$b$] {}(n);
        \draw[densely dashed] (0,0) -| node[pos=0.5, color=black, label=below:$x_{1}$] {}(m);
        \path [name intersections={of=B and A, by={c}}] node[fill,circle,inner sep=1pt] at (c) {}; 

    \end{axis}
\end{tikzpicture}

\end{document}

AND THIS IS WHAT I GOT:

Result from latex

  • Okay what is the function of the curve? Where is the code taken from? – user156344 May 23 '19 at 16:07
  • I got the code from here,tex.stackexchange.com/questions/394923/…, and from another question asked here. The curves are two differential equations which I plotted on DESMOS. However, I need to have the outcome from DESMOS in latex code. So they are exactly as drawn in the picture. – Tich May 23 '19 at 16:12
3

Is it even needed to have such a complicated code?

\documentclass[tikz]{standalone}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}[scale=0.6,>=stealth,
    dot/.style={circle,fill=black,inner sep=1pt}]
\draw[blue,thick] plot[samples=100,domain=-4:4.2] (0.5*\x*\x-2,\x);
\draw[blue,thick] plot[domain=-5:5] (\x+2,\x);
\draw[->] (-3,0) -- (8,0) node[above] {$x$};
\draw[->] (0,-5) -- (0,5) node[left] {$y$};
% The following coordinates are calculated using some (very simple) maths.
% For more complicated plots, you may need `intersections' library, but it 
% is not necessary here
\path (2,0) node[dot,label=below:$a$] {}
    (6,4) node[dot] {}
    (0,2) node[dot,label=above left:$c$] {}
    (0,-2) node[dot] {} node[above right=-5pt and 2pt] {$d$};
\draw[dashed] (6,4) -- (6,0) node[below] {$b$};
\end{tikzpicture}
\end{document}

enter image description here

2

Even though I agree with Joule V that this very plot can be done without pgfplots, using the latter pays off when you deal with more complicated functions that may throw dimension too large errors in plain TikZ. Also pgfplots makes sure that you get a plot of the right dimensions. It also has the advantage that xmin and so on are stored in pgf keys, which superficially makes the code longer but really makes it more universal, i.e. something like

\path[name path=yaxis] (0,\pgfkeysvalueof{/pgfplots/ymin}) -- (0,\pgfkeysvalueof{/pgfplots/ymax});

will work in any code and does not have to adjusted if you want to construct other examples.

\documentclass[tikz,border={15mm 15mm 15mm 15mm}]{standalone}
\usepackage{pgfplots} 
\pgfplotsset{compat=newest}
\pgfplotsset{plot coordinates/math parser=false}
\pgfplotsset{
    every non boxed x axis/.style={
        xtick align=center,
        enlarge x limits=true,
        x axis line style={line width=0.8pt, -latex}
},
    every boxed x axis/.style={}, enlargelimits=false
}
\pgfplotsset{
    every non boxed y axis/.style={
        ytick align=center,
        enlarge y limits=true,
        y axis line style={line width=0.8pt, -latex}
},
    every boxed y axis/.style={}, enlargelimits=false
}
\usetikzlibrary{
   arrows.meta,
  intersections,
}


\usetikzlibrary{calc}
%\pgfplotsset{compat=newest}
\usetikzlibrary{
   arrows.meta,
  intersections,}
% arrows as stealth fighters
\tikzset{>=stealth}
\begin{document}

\begin{tikzpicture}[bullet/.style={fill,circle,inner sep=1.5pt}]
    \begin{axis}[
            axis lines=middle,
            axis line style=<->,
            xmin=-5,xmax=8,
            ymin=-5,ymax=8,
            xlabel=$N_A$,
            ylabel=$N_B$,
            xtick=\empty,
            ytick=\empty,
            xticklabels=\empty,
            yticklabels=\empty,
        ]
        \addplot[thick,domain=-5:7,blue,name path=A,smooth]  ({0.5* x^2-2},{x}) coordinate[pos=0.4] (m) ;
        \addplot[thick,domain=-5:7,blue,name path=B]  ({ x+2},{x}) coordinate[pos=0.4] (n) ;
        \path[name path=yaxis] (0,\pgfkeysvalueof{/pgfplots/ymin}) -- (0,\pgfkeysvalueof{/pgfplots/ymax});
        \path[name path=xaxis] (\pgfkeysvalueof{/pgfplots/xmin},0) -- 
        (\pgfkeysvalueof{/pgfplots/xmax},0);

        \path [name intersections={of=A and B, by={d,b}}] 
        (d) node[bullet,label=below right:$d$] {}
        (b) node[bullet,label=below right:$b$] {};
        \draw[densely dashed] (b) -- (b|-0,0);
        \path [name intersections={of=A and yaxis, by={aux,c}}] 
        (c) node[bullet,label=above left:$c$] {};
        \path [name intersections={of=B and xaxis, by={a}}] 
        (a) node[bullet,label=below right:$a$] {};

    \end{axis}
\end{tikzpicture}

\end{document}

enter image description here

  • You seriously need a samples for the curve :) – user156344 May 23 '19 at 16:42
  • @JouleV smooth would do but this is really not the point of this answer. – user121799 May 23 '19 at 16:44
  • Of course, but a broken curve never satisfies at least my eyes – user156344 May 23 '19 at 16:45
  • 2
    @JouleV The number of posts on this site that pleases my eyes is very small, but IMHO that's not the point of them. The point is IMHO to exchange ideas how to do things in principle. – user121799 May 23 '19 at 16:47
  • You guys are the best. I have been at it for days now. Thank you !! – Tich May 23 '19 at 17:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.