\documentclass{article} \usepackage[pdftex,active,tightpage]{preview} \setlength\PreviewBorder{2mm} \usepackage{pgfplots} \usepackage{units} \pgfplotsset{compat=1.3}% <-- moves axis labels near ticklabels % (respects tick label widths) \usepackage{tikz} \usetikzlibrary{arrows, positioning, calc, intersections, decorations.markings} \usepackage{xcolor} \definecolor{horizontalLineColor}{HTML}{008000} \definecolor{verticalLineColor}{HTML}{FF0000} \begin{document} % Define this as a command to ensure that it is same in both cases \newcommand*{\ShowIntersection}[2]{ \fill [name intersections={of=#1 and #2, name=i, total=\t}] [red, opacity=1, every node/.style={above left, black, opacity=1}] \foreach \s in {1,...,\t}{(i-\s) circle (2pt) node [above left] {\s}}; } \begin{preview} \begin{tikzpicture} \begin{axis}[ label distance=0mm, width=8cm, height=7cm, % size of the image xmin= 40, % start the diagram at this x-coordinate xmax= 180, % end the diagram at this x-coordinate ymin=60, % start the diagram at this y-coordinate ymax=170, % end the diagram at this y-coordinate ylabel=y, xlabel=x, axis lines=left, tick style={draw=none}, xticklabels={,,}, yticklabels={,,} ] \addplot[name path global=a, domain=55:161, dotted, blue, very thick,samples=500, label=$y=f(x)$] {113/132078*x*x*x-11865/44026*x*x+1169437/44026*x-93155207/132078}; % ( 55 | 82.7344) and (161 | 156.011) are on the graph \coordinate (b) at (axis cs: 55,170); \coordinate (c) at (axis cs:161,170); \coordinate (d) at (axis cs:161,82.7344); \coordinate (e) at (axis cs:161,156.011); \coordinate (a1) at (axis cs:55,111.494); \coordinate (a2) at (axis cs:161,111.494); \draw[verticalLineColor, thick, <->](a1) -- (a2); \draw[verticalLineColor,dashed](b |- 0,0) -- (b); \draw[verticalLineColor,dashed](c |- 0,0) -- (c); \draw[horizontalLineColor,dashed, thick](d -| 0,0) -- (d); \draw[horizontalLineColor,dashed, thick](e -| 0,0) -- (e); % (100 | 111.494) \coordinate (f) at (axis cs:100, 111.494); \draw[red,dashed](f |- 0,0) -- (f); \end{axis} \end{tikzpicture} \end{preview} \end{document}