5

The following are my code. I used the axis environment for better axis style. I try to add nodes at g^W=g^L, which is a point on the y-axis, but the axis environment seemes to cut off anything outside the axis. What should I do?

\documentclass[11pt]{article}
\usepackage{pgfplots}
\begin{document}

\begin{figure}
\centering
\begin{tikzpicture}[scale = 1.2]
     \begin{axis}[xmin=0,xmax=10,ymin=0,ymax=7,
        axis lines = left, axis line style = thick,  unit vector ratio=1 1 1, xtick={0,8},
        xticklabels = {$p^w=0$, $p^w=1$},
        ytick={1.5,3,5.5},
        yticklabels = {$g^L-\beta$,$g^W=g^L$,$g^w+\alpha$}]
        \addplot[mark=none, dashed] coordinates {(8, 0) (8, 7)}; 
        \addplot[domain=0:8, dashed] {1.5};
        \addplot[domain=0:8, dashed] {3};

        \node[black,right] at (axis cs:8,1.5){\small{$W=0$}};
        \node at (axis cs:8,1.5) [circle, scale=0.3, draw=black!80,fill=black!80] {};
        \node at (axis cs:8,3) [circle, scale=0.3, draw=black!80,fill=black!80] {};
        \node at (0,3.5) [circle, scale=0.3, draw=black!80,fill=black!80] {};
      \end{axis}
\end{tikzpicture}
\caption{A caption.}
\end{figure}

\end{document}

enter image description here

7

If you add

clip mode=individual 

to the axis options, the diagrams (with addplot) will be clipped, but the nodes will not.

Otherwise, clip = false will avoid any clipping.

PS: you need a \pgfplotsset{compat=1.9} or whatever added, to avoid surprises...

| improve this answer | |
  • It worked! Thanks. Just a question, what does clip mean? – Kun Apr 2 '16 at 14:18
  • 1
    clip means to cut off all that will go outside the axis range. Imagine a function like 1/x which will go unbounded otherwise... – Rmano Apr 2 '16 at 14:23

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.