2

Is it possible to plot the function 1/{1+\frac{1}{x}} from 0 to 20 using tikzpicture, when I do it I just get a straight line

\documentclass{article}
\usepackage{pgfplots}

\begin{document}

    \begin{tikzpicture}
    \begin{axis}

    \addplot[smooth,samples=180,domain=0:0.5]{1/{1+{1/x}}};

    \end{axis}
    \end{tikzpicture} 
\end{document} 
  • 2
    Welcome to TeX.SX! Please help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – user31729 Feb 2 '15 at 16:04
  • Sure it's possible: \documentclass{article} \usepackage{pgfplots} \begin{document} \begin{tikzpicture} \begin{axis} \addplot[smooth,samples=180,domain=0.0001:20]{1/(1+(1/x))}; \end{axis} \end{tikzpicture} \end{document} The result: i.imgur.com/DWYNRap.png – Gonzalo Medina Feb 2 '15 at 16:44
1

You are using

{1/{1+{1/x}}}

and you should use

{1/(1+(1/x))}

instead. A complete example:

\documentclass{article}
\usepackage{pgfplots}

\begin{document}    

\begin{tikzpicture}
\begin{axis}
  \addplot[smooth,samples=180,domain=0.0001:20] {1/(1+(1/x))};
\end{axis}
\end{tikzpicture} 

\end{document} 

enter image description here

  • for some reason x runs from -6 to 6. Is it because I am using other packages like \usepackage{hyperref,multicol,lipsum,geometry,titlesec,fancyhdr,amsmath,MnSymbol,wasysym,fleqn,mathtools}% – MrDi Feb 2 '15 at 16:49
  • @user28952 Hard to tell from the information given. What do you get when pasting the exact same code I posted in a new fresh test document? – Gonzalo Medina Feb 2 '15 at 16:52
  • I still get the same result, x runs from -6 to 6. Even when using your exact code.. – MrDi Feb 2 '15 at 16:59
  • @user28952 which version of pgfplots are you using? – Gonzalo Medina Feb 2 '15 at 17:03
  • I don't know, How can I check that? – MrDi Feb 2 '15 at 17:05

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.