3
\documentclass{article}
\usepackage{tikz}
\usepackage{pgfplots}
\usepackage{tkz-euclide}
\begin{document}    
\begin{tikzpicture}
    \begin{axis}[ticks=none,
            xtick={-10,-9,...,10},   
            xmin=-6,
            xmax=6,
            xlabel={$\alpha$},
            axis x line=middle,
            ytick={-10,-9,...,10},
            ymin=0,
            ymax=10,
            ylabel={$s$},
            axis y line=middle,
            no markers,
            samples=100,
            domain=-10:10,
            restrict y to domain=-20:20, xscale=1.2 ]
        \addplot[green,samples=400] (x,{-1/x});
        \addplot[blue,samples=400] (x,{1/(1+2*x)});
        \addplot[red,samples=400, domain=-1:1] (x,{-4*x/(1+x)^2}) node[pos=0.5, pin=135:{$\frac{-4\alpha}{(1+\alpha^2)}$}] {};
        \draw[cyan] (axis cs:1,0) -- (axis cs: 1,10) node[pos=1, pin = -30: {\tiny $\alpha=1$}] {};
        \draw[cyan] (axis cs:-1,0) -- (axis cs: -1,10) node[pos=0.5, pin = -120: {\tiny $\alpha=-1$}] {};
    \end{axis} 
    \end{tikzpicture}
\end{document}

My one plot label \addplot[red,samples=400, domain=-1:1] (x,{-4*x/(1+x)^2}) node[pos=0.5, pin=135:{$\frac{-4\alpha}{(1+\alpha^2)}$}] {}; doesn't want to display for some reason. Does anyone see a problem with my code?

2

The label is outside of the axis rectangle, so it is cliped away. You can add an option clip=false, to the axis environment, but that would "unclip" the plots of your functions, which probably isn't what you want. Another option would be moving the red label so it is comnpletely inside of the axis rectangle.

  • Thank you for your response. Maybe I don't understand the pos and pin stuff. How can I get it back in the area? – user21359 Oct 9 '13 at 15:10
  • @user21359 -- Try the third addplot, change 135 to -135 should bring the formula back. – Jesse Oct 9 '13 at 15:38
  • I might be missing something but that still doesn't bring up the label? Where is it that I can't see it? – user21359 Oct 10 '13 at 5:12

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.