# misaligned psplot psline in pstricks

I am trying to draw a figure using pstricks and pst-plot, compiling to a PDF with XeLaTeX. I find that lines drawn with the \psplot and \psline commands are horizontally displaced from where I want them to be, relative to axes plotted with \psaxes (see below).

The x-axis runs from 0 to 5. I think my code should place each of the three horizontal lines in the figure directly above the x-axis, also running from 0 to 5. But they are out of alignment with the x-axis. Why? My code is:

\documentclass[11pt,twoside,a4paper]{article}

\usepackage{pstricks}
\usepackage{pst-plot}

\begin{document}

\begin{figure}
\centering
\begin{pspicture}*(0,0)(12.5,12.5)
\psaxes[linewidth=1.2pt,labels=none,ticks=none,origin={0.5,7}]{->}(0,0)(0,0)(5,5)
\psline[linestyle=dashed,origin={0.5,7}](0,0)(5,5)]
\psline[origin={0.5,7}](0,1.2)(5,1.2)]
\psline[origin={0.5,7}](0,0.8)(5,0.8)]
\psplot[plotpoints=50,origin={0.5,7}]{0}{5}{1}
\end{pspicture}
\end{figure}

\end{document}

• Just remove the three spurious ] at the end of the \psline commands. – Bernard Nov 17 '14 at 8:59

the ] at the end of your \psline are printed as a normal character. The reason why your origin of the coordinate system is shifted to the right by the width of this character. And this happens three times.

Remove the star of your pspicture environment and you'll see what happens. The three ] are placed relative to the origin of the coordinates system:

\documentclass[11pt,twoside,a4paper]{article}
\usepackage{pst-plot}

\begin{document}

\begin{pspicture}[showgrid](0,0)(6,12.5)
\psaxes[linewidth=1.2pt,labels=none,ticks=none,origin={0.5,7}]{->}(0,0)(0,0)(5,5)
\psline[linestyle=dashed,origin={0.5,7}](0,0)(5,5)]
\psline[origin={0.5,7}](0,1.2)(5,1.2)]
\psline[origin={0.5,7}](0,0.8)(5,0.8)]
\psplot[plotpoints=50,origin={0.5,7}]{0}{5}{1}
\end{pspicture}

\end{document}


Simply remove the ] or use \rput if you really want it