[Tex/LaTex] Dimension too large while plotting with pgfplots


I have the following pgfplots code:

\foreach \i in {-10,-9.8,...,10} {\addplot+[smooth] {-x/\i+\i};}%

I need several line-plots in order for the parabolic pattern to emerge, hence the for loop with a 0.2 increment. Unfortunately, this gives me the dimension too large error. What can I do?

Best Answer

Besides the obvious 1/0 division, the question is not about math but about TeX, i.e. why pgfplots fails. pgfplots probably complains because whatever internal represenation of 1/0 is "too large" to be plotted. The solution is to use restrict y to domain



\begin{axis}[domain=-8:2, restrict y to domain=-10:10]
\foreach \i in {-10,-9.8,...,10} {\addplot+[no markers, solid, smooth] {-x/\i+\i};}%


(Having said that, it is anyway dangerous to allow a division by zero in general.)

emerging parabola

Related Question