3

I am new to LaTeX and I want to know how to plot the following function using TikZ:

y = 300 + 1000/x + 2.5x.

at the interval 0:250

3

Here is a version adapted from Easiest way to plot a function with PGF/TikZ.

One does not need to use \pgfmathdeclarefunction, but I find it easier to maintian code if each function is declared as such.

enter image description here

Code:

\documentclass{article}

\usepackage{pgfplots}% This uses tikz
\pgfplotsset{compat=newest}% use newest version

\pgfmathdeclarefunction{Function}{1}{%
  \pgfmathparse{300 + 1000/x + 2.5}%
}

\tikzset{My Line Style/.style={smooth, ultra thick, samples=400}}

\begin{document}
\begin{tikzpicture}
\begin{axis}[unbounded coords=discard]
    \addplot[My Line Style, color=blue, domain=0:250] (\x,{Function(\x)});
\end{axis}
\end{tikzpicture}
\end{document}
\documentclass{article}
|improve this answer|||||

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.