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 would like to add a plot to a pgfplots figure, but such that it doesn't change the automatically computed limits. for example:

\documentclass{article}
\usepackage{tikz,pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}%[ymin=-6,ymax=6]
\addplot+ {x};
\addplot+ {x^2};
\end{axis}
\end{tikzpicture}
\end{document}

As written, the secont plot alters the limits. I could manually specify the limits (by removing the comment), but that's precisely what I want to avoid. Is there an option for this? I've found the forget plot option, but that's not quite what I need.

share|improve this question
2  
I see a pgfplotsinterruptdatabb environment in the pgfplots documentation, isn't that what you are looking for? –  T. Verron Mar 11 at 13:30

1 Answer 1

up vote 10 down vote accepted

For a single plot, you can use the option update limits=false.

For several plots, you can wrap them in the environment pgfplotsinterruptdatabb.

In both cases, the result is the same: the given plots do not contribute to the computation of the bounding box.

\documentclass{article}
\usepackage{tikz,pgfplots}
\begin{document}

\begin{tikzpicture}
  \begin{axis}%[ymin=-6,ymax=6]
    \addplot+ {x};
    \addplot+ {x^2};
  \end{axis}
\end{tikzpicture}

\begin{tikzpicture}
  \begin{axis}%[ymin=-6,ymax=6]
    \addplot+ {x};
    \addplot+[update limits=false] {x^2};
  \end{axis}
\end{tikzpicture}

\begin{tikzpicture}
  \begin{axis}%[ymin=-6,ymax=6]
    \addplot+ {x};
    \begin{pgfplotsinterruptdatabb}
      \addplot+ {x^2};
    \end{pgfplotsinterruptdatabb}
  \end{axis}
\end{tikzpicture}

\end{document}

enter image description here

share|improve this answer
    
Yep, that's exactly what I was looking for, but with such a big manual it's sometimes difficult to find things (and I was expecting to see some example). Now I have to solve a problem with dimensions too large (not in this test, but in my real case) –  Jellby Mar 11 at 14:31

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.