Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm trying to draw a relatively simple chart of a number line, and when one of the nodes is too close to the edge of the plot, it gets cut off.

The code:

\documentclass{article}

\usepackage{natbib}
\usepackage{graphicx}
\usepackage{pgfplots}

\begin{document}

\begin{tikzpicture}
\begin{axis}[
  width=\columnwidth,
  axis y line=none,
  axis lines=left,
  axis line style={-},
  xmin=0,
  xmax=1,
  ymin=0,
  ymax=1,
  xlabel=$\mu$,
  scatter/classes={o={mark=*}},
  restrict y to domain=0:1,
  xtick={0,1}
]
\draw[ultra thin] (axis cs:0, 0) -- (axis cs:0,.05);
\draw[ultra thin] (axis cs:.4, 0) -- (axis cs:.4,.05);
\node[coordinate,label=above:{$B$}] at (axis cs:0.0,0.05) {};
\node[coordinate,label=above:{$A$}] at (axis cs:0.4,0.05) {};
\node[coordinate,label=above:{$b$}] at (axis cs:0.2,0.02) {};
\node[coordinate,label=above:{$a$}] at (axis cs:0.7,0.02) {};
\end{axis};
\end{tikzpicture}
\end{document}

The Result:

Partially rendered node label

How do I get the B to fully render?

share|improve this question

1 Answer 1

up vote 4 down vote accepted

By default any paths inside the axis bounding box is clipped, this is what cuts the B. To turn off clipping, add clip=false to the axis options.

Clipping is discussed in section 4.19.2 Clipping of the manual (for version 1.8 of pgfplots, dated 2013-03-07).

As mentioned by Jake in a comment: In version 1.8 of pgfplots the key clip mode=individual was introduced, which will clip plot lines, but not normal nodes.

\documentclass{article}

\usepackage{natbib}
\usepackage{graphicx}
\usepackage{pgfplots}

\begin{document}

\begin{tikzpicture}
\begin{axis}[
  width=\columnwidth,
  axis y line=none,
  axis lines=left,
  axis line style={-},
  xmin=0,
  xmax=1,
  ymin=0,
  ymax=1,
  xlabel=$\mu$,
  scatter/classes={o={mark=*}},
  restrict y to domain=0:1,
  xtick={0,1},
  clip=false    % <-- new addition
  % clip mode=individual  % alternative
]
\draw[ultra thin] (axis cs:0, 0) -- (axis cs:0,.05);
\draw[ultra thin] (axis cs:.4, 0) -- (axis cs:.4,.05);
\node[coordinate,label=above:{$B$}] at (axis cs:0.0,0.05) {};
\node[coordinate,label=above:{$A$}] at (axis cs:0.4,0.05) {};
\node[coordinate,label=above:{$b$}] at (axis cs:0.2,0.02) {};
\node[coordinate,label=above:{$a$}] at (axis cs:0.7,0.02) {};
\end{axis};
\end{tikzpicture}
\end{document}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.