I have occasionally observed that some LaTeX macros behave differently with and without end-of-line comments. My understanding of this is that a macro may leave a space on the stack that for some reason is removed if the macro is ended with a percent sign. I have never quite understood why this happens so I've slowly fallen into the habit of ending all "function calls" in LaTeX with %. In the present case, I discovered that \pstScalePoints and \newpsstyle behaves just like that and took the effort to isolate the problem into the following MWE:
\documentclass{standalone}
\usepackage{pstricks}
\usepackage{pstricks-add}
\usepackage{pst-plot}
\listfiles
\begin{document}
\readdata{\mytable}{table.txt}
\pstScalePoints(1.0,1.0){1.0 div}{1.0 div}% <-- NB!
\newpsstyle{legendstyle}{fillstyle=solid}% <-- NB!
\begin{psgraph}(0,0)(0,0)(1,1){1cm}{1cm}
\listplot{\mytable}
\end{psgraph}
\end{document}
Problem: The output changes if the two end-of-line % signs are removed. My suspicion is that the macros leave behind a space on the stack, but I do not know how to correct it - other than stubbornly adding % to all the macro endings!
The contents of file table.txt is:
0.0, 0.00
0.2, 0.04
0.4, 0.16
0.6, 0.36
0.8, 0.64
1.0, 1.00
I halfway expect that the problem depends on which packages I am using so I therefore include the output from \listfiles:
pstricks.sty 2013/12/12 v0.60
pstricks.tex 2014/10/25 v2.60
pst-xkey.tex 2005/11/25 v1.6
pst-fp.tex 2014/10/25 v2.60
pstricks-add.sty 2010/02/11 v.0.14
pst-plot.sty 2011/04/13
pst-xkey.sty 2005/11/25 v1.6
pst-plot.tex 2014/08/23 1.70
pst-node.sty 2010/04/22
pst-node.tex 2014/08/04 1.35
pstricks-add.tex 2014/12/08 v3.77
pstricks-add.cfg 2005/01/10 v0.1
Finally, I've attached two pictures illustrating the problem:


\abc, then the space is consumed as part of the parsing rules of TeX. The other situation is that the command explicitly consumes the space, like\beginor\endstatements do, and apparently also\readdatadoes. You can achieve the same effect for your own macro definitions by ending them with\ignorespaces. – gernot Jan 01 '17 at 17:26standalonetypesets its contents in a horizontal box, so spaces are significant. You need also a%after\readdata{\mytable}{table.txt}. In a normal document those spaces would be ignored since LaTeX has not yet started a paragraph. – egreg Jan 01 '17 at 17:46%behaviour is related to macros which is not the case. comparea<newline>bwhich typesets asa bbut if you comment out the newline then naturally it comments out the space so you getab– David Carlisle Jan 01 '17 at 21:24standalone. I did not come to my mind that it works in horisontal mode! On the other hand, I cannot see any difference if\readdatais ended with%or not. Is there something I have (still) misunderstood? – Tore H-W Jan 01 '17 at 22:50\readdatacalls an inner macro whose replacement text ends with\ignorespaces, so indeed it does not matter whether you have%after that line. Just checked. I was bitten by the issue a couple of times, so I learnt about it. – egreg Jan 01 '17 at 22:56\beginand\endexplicitly consume the space, I know I should read up a bit. – Tore H-W Jan 01 '17 at 23:02