# How to plot following graph

• With package pgfplot this should be relative simple. First, you manual accompanied with package, then determine functions for your graphs, and on basis of numerous examples given in the manual construct minimal working example ant provide it to SE. Then some can more easy help you. – Zarko Jul 31 '14 at 8:05
• Welcome to TeX.SX! You write: "but I could not". Please let us know what you have tried. How should we help you without this information. And you should give much more information: Are the colours important, the differing fonts, the arrow heads... – LaRiFaRi Jul 31 '14 at 8:26

You can use the pgfplots package to render that plot, because I did not have your functions, I used some sample functions (the same functions the others have used in their answers to your question). You can use this code as a template to produce your own plots.

Note that the pgfplots package manual is so perfect, has many different examples (and options) and easy to read. I am a basic user of LaTeX, but in a short period of time, I understood how should I work with the package.

\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.9}

\begin{document}
\begin{tikzpicture}

\begin{axis}
[
axis lines = center,
xlabel=$x$,ylabel=$y$,
domain=-2:10,
samples=100,
]
\node at (axis cs:5,4) [pin={60:$y=\frac{A}{\alpha+d}$},inner sep=0pt] {};
\addplot [black, mark = *] coordinates {( 4, 0)} node[pin=-60:{$M_C^*$},inner sep=0pt] {};
\addplot [black, mark = *] coordinates {( 0.33, 0)} node[pin=-60:{$M_C$},inner sep=0pt] {};
\addplot [black, mark = *] coordinates {( 1.832835, 2.23858)} node[pin=-2:{$(M_3^*, Y^*)$},inner sep=0pt] {};
\end{axis}
\end{tikzpicture}
\end{document}


and here is the output:

You can use lualatex alongside this package too. See the previous edit of my answer to see an example of how to use it with pgfplots package and how complicated functions can be plotted. Regarding a comment to this answer:

lualatex can be considered as a way to avoid memory restrictions (often needed) or to avoid numerical inaccuracies (almost never necessary).

P.S. Because a bounty is started on this question, I edited my answer to have an output which looks like the other answers on the question but using a different LaTeX code. For previous codes please see the revisions of my answer.

• Good answer! Just for the records: note that you do not need lualatex here - it is sufficient to use \addplot [solid, thick] {x^2}; and \addplot [dashed, thick] {x^3};, respectively. – Christian Feuersänger Aug 5 '14 at 19:29
• @ChristianFeuersänger After I finish my thesis, I really want to spend some time to learn more about the lualatex and pgfplots. I should again thank you that introduced me this package for latex. – Enthusiastic Engineer Aug 5 '14 at 19:31
• You are welcome. My best wishes for your thesis! Regarding the interaction of pgfplots and lualatex: lualatex can be considered as a way to avoid memory restrictions (often needed) or to avoid numerical inaccuracies (almost never necessary). For all other cases, you do not need it. This holds for all versions of pgfplots up to and including 1.10 (the current stable). – Christian Feuersänger Aug 5 '14 at 20:05
• @ChristianFeuersänger Thanks, I edited my answer to both make the answer code easier/simpler and to mention a little information about lualatex. – Enthusiastic Engineer Aug 5 '14 at 20:19

Here is a tikz-ish version of Please don't touch's answer. I think the code doesn't need more explanation, but in doubt just ask.

Updated Version - See version history

\documentclass[border=5mm, 12pt, tikz]{standalone}
\usetikzlibrary{calc, intersections, arrows, shapes, positioning, fit, backgrounds}

\begin{document}
\begin{tikzpicture}[domain=-1:10, samples=250]
% Function definitions
\newcommand{\f}{2^(-\x/2+3)-2}
\newcommand{\g}{4}
\newcommand{\h}{\g*(1-1.12^(-3*\x+1))}
\begin{scope}
% Plots, clipped draw area
\clip (-1,-2) rectangle (10,8);
\draw[ultra thick, blue, name path=ff] plot ({\x}, {\f});
\draw[ultra thick, red,  name path=fg] plot ({\x}, \g) node [black, above left] {$Y=\frac{A}{\alpha+d}$};
\draw[ultra thick, green!75!black, name path=fh] plot  ({\x}, {\h});
% Axes
\draw [thick, ->, >=triangle 45, name path global=yaxis] (0,-2) -- (0,8) node [above] {$Y$};
\draw [thick, ->, >=triangle 45, name path global=xaxis] (-2,0) -- (10,0) node [right] {$M$};
% Intersections
\fill [name intersections={of=ff and xaxis}] (intersection-1) circle (.1cm) node [below=.5cm] {$M_c^*$};
\fill [name intersections={of=fh and xaxis}] (intersection-1) circle (.1cm) node [below=.5cm] {$M_c$};
\fill [name intersections={of=ff and fh}] (intersection-1) circle (.1cm) node [right=.5cm] {$M_3^*,Y^*$};
\end{scope}

% Legend
\begin{scope}[text width=4cm, node distance=0cm]
\node at (10,8) [below left, blue] (y1) {$\bullet$ $y=2^{-x/2+3}-2$};
\node [below=of y1, red] (y2) {$\bullet$ $y=4$};
\node [below=of y2, green!75!black] (y3) {$\bullet$ $y=4(1-1.2^{-3x+1})$};
\end{scope}
\begin{scope}[on background layer]
\node [rectangle, draw, thick, fit=(y1) (y2) (y3)] () {};
\end{scope}
\end{tikzpicture}
\end{document}


Run with xelatex

\documentclass{article}
\usepackage{pst-plot,pst-intersect,mathtools}
\begin{document}

\begin{pspicture}(-2,-2)(8,8)
\psaxes[labelFontSize=\scriptstyle,ticksize=0 4pt]{->}(0,0)(-2,-2)(8,8)[$M$,-90][$Y$,0]
\psset{linewidth=1.5pt,algebraic}
\pssavepath[linecolor=green]{A}{\psplot{-0.5}{8}{4*(1-1.2^(-3*x+1))}}
\psline[linecolor=red](-2,4)(8,4) \uput[90](7,4){$Y=\dfrac{A}{\alpha+d}$}
\pssavepath[linecolor=blue]{B}{\psplot{-0.5}{8}{2^(-x/2+3)-2}}
\pssavepath[linestyle=none]{C}{\psplot{-0.5}{8}{0}}
\psintersect[name=D, showpoints]{A}{B}\uput[0](D1){$M_3^*,Y^*$}
\psintersect[name=E, showpoints]{A}{C}\uput[-45](E1){$M_c$}
\psdot(4,0)\uput[225](4,0){$M_c^*$}
\end{pspicture}

\end{document}


• where did you introduce the functions to be plotted in your code? – Enthusiastic Engineer Aug 5 '14 at 8:07
• \psplot(start}{end}{function} – user2478 Aug 5 '14 at 8:35
• A typo is detected. The syntax is \psplot{start}{end}{function}. – kiss my armpit Aug 6 '14 at 6:10
\documentclass[pstricks,12pt,dvipsnames]{standalone}
\usepackage{amsmath}

\usepackage{pst-eucl}
\usepackage{pst-plot}

\usepackage[nomessages]{fp}

\FPeval\XMin{0-2}
\FPeval\XMax{5}
\FPeval\YMin{0-4}
\FPeval\YMax{8}

\FPeval\XOL{0-1/3} % of DeltaX
\FPeval\XOR{1/3} % of DeltaX
\FPeval\YOB{0-1/2} % of DeltaY
\FPeval\YOT{1/2} % of DeltaY

\FPeval\DeltaX{1}
\FPeval\DeltaY{1}

\FPeval\AxisL{XMin+DeltaX*XOL}
\FPeval\AxisR{XMax+DeltaX*XOR}
\FPeval\AxisB{YMin+DeltaY*YOB}
\FPeval\AxisT{YMax+DeltaY*YOT}

\newlength\Width\Width=10cm
\newlength\Height\Height=10cm

\newlength\llx\llx=-5pt
\newlength\urx\urx=20pt
\newlength\lly\lly=-5pt
\newlength\ury\ury=20pt

\psset
{
llx=\llx,
lly=\lly,
urx=\urx,
ury=\ury,
labelFontSize=\scriptstyle,
xAxisLabel=$M$,
yAxisLabel=$Y$,
algebraic,
plotpoints=500,
yMaxValue=\YMax,
yMinValue=\YMin,
}

\def\f{2^(-x/2+3)-2}
\def\g{4}
\def\h{\g*(1-1.2^(-3*x+1))}

\begin{document}
\pslegend[rt]{%
\color{NavyBlue}\rule{12pt}{1pt} & \color{NavyBlue} $y=2^{-x/2+3}-2$ \\
\color{Red}\rule{12pt}{1pt} & \color{Red} $y=4$ \\
\color{ForestGreen}\rule{12pt}{1pt} & \color{ForestGreen} $y=4(1-1.2^{-3x+1})$
}
\begin{psgraph}[ticks=none,labels=none]{<->}(0,0)(\AxisL,\AxisB)(\AxisR,\AxisT){\dimexpr\Width-\urx+\llx}{\dimexpr\Height-\ury+\lly}
\psplot[linecolor=NavyBlue]{\XMin}{\XMax}{\f}
\psplot[linecolor=Red]{\XMin}{\XMax}{\g}
\psplot[linecolor=ForestGreen]{\XMin}{\XMax}{\h}
\pstInterFF[PosAngle=-135]{\f}{0}{3}{M_c^*}
\pstInterFF[PosAngle=-45]{\h}{0}{0}{M_c}
\pstInterFF[PointName={(M_3^*,Y^*)},PointNameSep=36pt]{\f}{\h}{0}{temp}
\uput[90](-1,\g){$Y=\frac{A}{\alpha + d}$}
\end{psgraph}
\end{document}


And here's a simple version in plain Metapost. Most of this is explained in the Metapost introduction, and all of it in the Metapost manual.

Note in particular that you don't need to know the formulas for the curves. You can just sketch them using the direction notation as shown, and use intersectionpoint to find the point where they cross.

prologues := 3;
outputtemplate := "%j%c.eps";

beginfig(1);

u := 1.3cm;
minx = -2u; maxx = 6u;
miny = -2u; maxy = 4u;
h = 2u;

path x.axis, y.axis, curve[];

x.axis = (minx,0) -- (maxx,0);
y.axis = (0,miny) -- (0,maxy);

label.top(btex $Y$ etex, (0,maxy));
label.rt (btex $M$ etex, (maxx,0));

curve1 = (-1u, miny) {dir  70} .. {dir   3} (maxx,.9h);
curve2 = (-1u, maxy) {dir -80} .. {dir -10} (maxx,-1u);

drawarrow x.axis withcolor .67 red;
drawarrow y.axis withcolor .67 red;

draw (minx,h) -- (maxx,h) dashed evenly scaled .8;
label.urt(btex $\displaystyle Y={A\over\alpha+d}$ etex,(minx,h));

draw curve1;
draw curve2;

dotlabel.lrt (btex $M_c$   etex, x.axis intersectionpoint curve1);
dotlabel.llft(btex $M_c^*$ etex, x.axis intersectionpoint curve2);

% do the last dot label by hand to avoid over printing the curves
z1 = curve1 intersectionpoint curve2;
fill fullcircle scaled dotlabeldiam shifted z1;
label(btex $\quad(M_3^*,Y^*)$ etex, z1 + 26 right);

endfig;
end.