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.

Consider the example below:

\documentclass{article}
\usepackage{tikz,pgfplots}
\pgfplotsset{compat=newest}
\usepackage{animate}
\pgfmathdeclarefunction{normal}{2}{%
  \pgfmathparse{1/(#2*sqrt(2*pi))*exp(-((x-#1)^2)/(2*#2^2))}%
}
\begin{document}
\begin{figure}[ht]
\begin{center}
\begin{animateinline}[controls,palindrome]{5}
  \multiframe{15}{ik=1+1}{
\begin{tikzpicture}
\begin{axis}[
      hide y axis,
      axis lines*=center, 
      axis on top,
      no markers, 
      domain=0:25, 
      samples=100,
      xlabel=\empty, 
      ylabel=\empty,
      every axis x label/.style={at=(current axis.right of origin),anchor=west},
      every axis y label/.style={at=(current axis.above origin),anchor=south},
      xmin = 0, xmax = 25,
      ymin = 0, ymax = 1,
      xtick=, ytick=data,
      enlargelimits=false, 
      clip=false
  ]
  \addplot [very thick,cyan!90,draw opacity=.6*(1-\ik/7.5)*(1-\ik/7.5)] {normal((12-4.75*\ik/15),(4-3.75*\ik/15))/(\ik/3.75)};
\end{axis}
\end{tikzpicture}
}
\end{animateinline}
\end{center}
\end{figure}
\end{document}

As you can see, during the animation the axis stretches. I want to fix the axis (and the graph) to use a set coordinate system without deviating from it. So it will show e.g. the scope of x=[0,4] and y=[0,4], regardless of the intervals of the curve (in this case the curve has a variable height in the y-direction, causing the axis to stretch to compensate). Alternatively, a key, for instance fix axes to set coordinate system or something, is what I'm looking for.

share|improve this question
    
This happens because you're hiding the y axis. You can correct the bounding box by adding a dummy node using \node (dummy) at (rel axis cs:0,1) {}; just before \end{axis}. –  Jake Jun 4 at 9:54
    
@Jake Worked perfectly. :-) You can post it as an answer if you wish? –  1010011010 Jun 4 at 10:20

1 Answer 1

up vote 4 down vote accepted

This happens because you're hiding the y axis. You can correct the bounding box by adding a dummy node using \node (dummy) at (rel axis cs:0,1) {}; just before \end{axis}.

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.