I am facing a problem with setting the limits of my plot in pgfplots. The following script (from an answer here )
\documentclass[border=5mm]{standalone}
\usepackage{pgfplotstable}
\begin{document}
\begin{tikzpicture}
\pgfmathsetmacro{\XMax}{1.1e-3} %changing this to 1.05e-3 gives error
\pgfmathsetmacro{\XMin}{0.95e-3}
\begin{axis}[
xmin=\XMin,
xmax=\XMax
]
\pgfplotstableread{
x y dydx
0.96e-3 2 1
0.98e-3 1 -1
0.99e-3 3 0.5
}\mydata
% get number of rows in table
% subtract 1 because row indexing starts at zero
\pgfplotstablegetrowsof{\mydata}
\pgfmathtruncatemacro{\NumRows}{\pgfplotsretval-1}
\pgfmathsetmacro{\AxRange}{\XMax-\XMin}
\pgfplotsinvokeforeach{0,...,\NumRows}{ % loop over rows
% extract the data from the table
\pgfplotstablegetelem{#1}{x}\of\mydata
\pgfmathsetmacro{\X}{\pgfplotsretval}
\pgfplotstablegetelem{#1}{y}\of\mydata
\pgfmathsetmacro{\Y}{\pgfplotsretval}
\pgfplotstablegetelem{#1}{dydx}\of\mydata
\pgfmathsetmacro{\DYDX}{\pgfplotsretval}
% calculate start and end of domain for line
\pgfmathsetmacro{\DomainStart}{\X-\AxRange*0.1}
\pgfmathsetmacro{\DomainEnd}{\X+\AxRange*0.1}
% plot
\addplot +[domain=\DomainStart:\DomainEnd,mark=none,thick,samples=2] {\Y + \DYDX * (x-\X)};
}
\end{axis}
\end{tikzpicture}
\end{document}
creates the following figure.
But changing the value of Xmax to 1.05e-3 gives the following error.
Package pgfplots Warning: running in backwards compatibility mode (unsuitable tick labels; missing features). Consider writing \pgfplotsset{compat=1.14} into your preamble.
on input line 4.
Runaway definition?
->
./a.tex:40: TeX capacity exceeded, sorry [main memory size=5000000].
\pgfplotsapplistXXpushback@smallbufoverfl ...toka
\the \t@pgfplots@tokb \the...
l.40 }
./a.tex:40: ==> Fatal error occurred, no output PDF file produced!
Transcript written on /Users/manav/Desktop/.texpadtmp/a.log.
Why would the output be so sensitive to the xmax limit? Is there anything that can be done to force this limit without running into the error?


\addplot coordinatespreferred here as opposed to thedomainapproach in the original code? – user6593 Jul 06 '18 at 11:30xfpas well, though you might not see any difference in the output. – Torbjørn T. Jul 06 '18 at 11:38addplotline with this\addplot +[domain=\XStart:\XEnd,mark=none,samples=2] {\Y + \DYDX * (x-\X)};and it gave the same result. – user6593 Jul 06 '18 at 11:41yvalues in the data to2.e-6 1.e-6 3.e-6makes all plots to start from zero. It appears that there is a lower limit that pgfplots can handle. I tried reducing the exponent frome-0toe-6and this problem showed up ate-5. Is there a way to handle these numbers? – user6593 Jul 06 '18 at 12:24