2

The following animation shows the behavior intuitively. \psplot seems to work in an asymmetric way. It can plot the right part with the default plotpoints but it is not the case when it plots the left part. We need to increase the plotpoints to obtain the complete graph on the left part.

enter image description here

\documentclass[pstricks,border=12pt]{standalone}
\usepackage{pst-plot}

\pstVerb{/myDiv {dup 0 eq {pop 0 lt {-1e30} {1e30} ifelse} {div} ifelse} def}

\def\f#1{1 #1 myDiv}
\def\g#1{\f{#1 neg}}


\psset{yMinValue=-4,yMaxValue=4}

\begin{document}
\multido{\i=7+12}{20}{%
\psset{plotpoints=\i}
\begin{pspicture}[showgrid=bottom](-2,-4)(2,4)
\psclip{\psframe[linestyle=none,dimen=middle](-2,-4)(2,4)}
    \psplot[linecolor=red]{-2}{2}{\f{x}}
    \psplot[linecolor=blue]{-2}{2}{\g{x}}
    \rput(0,0){\textcolor{red}{plotpoints: \i}}
\endpsclip
\end{pspicture}}
\end{document}

Why does \psplot need higher plotpoints when plotting a function on the left of the function's asymptote? Is it a bug?

  • you are plotting one function with a vertical asymptote in it. on the left the last line segment is plotted to (x|y<MaxValue) on the right the first line is plotted from (x|y>MaxValue) to (x|y<MaxValue). That is different to the plotstyle dots where you get a symmetrical behaviour. – user2478 Aug 24 '12 at 9:51
  • @Herbert: Is it a good idea to add an option to \psplot to specify the asymptote x=a such that the \psplot can choose the correct starting points for both sides around the asymptote line? – kiss my armpit Aug 24 '12 at 9:59
  • in general yes, but at the moment too much work ... – user2478 Aug 24 '12 at 10:03
3

for an even number of plotpoints the x values are not symmetrical to the y axis, the reason why you didn't reach the not allowed division by zero 1/0 but have not the same distance of the points from the y axis. Choosing an odd number of plotpoints, eg 13, creates symmetrical x values but also has x=0 in the set. However, 1/0 can be catched by an own division operator and plotpoints=6*n+1 with n=1,2,... will give a symmetrical behaviour for this kind of function.

\documentclass[pstricks,border=12pt]{standalone}
\usepackage{pst-plot}

\begin{document}
\pstVerb{ % control the division, y x is on the stack
  /myDiv { dup 0 eq { pop 0 lt { -1e30 }
                               {  1e30 } ifelse } 
       { div } ifelse } def
}

\psset{plotpoints=24,plotstyle=dots}
\begin{pspicture}[showgrid=bottom](-2,-5)(4,5)
    \psplot[linecolor=red]{-2}{4}{1 x myDiv}
    \psplot[linecolor=blue]{-2}{4}{-1 x myDiv}
\end{pspicture}

\psset{plotpoints=25,plotstyle=dots}
\begin{pspicture}[showgrid=bottom](-2,-5)(4,5)
    \psplot[linecolor=red]{-2}{4}{1 x myDiv}
    \psplot[linecolor=blue]{-2}{4}{-1 x myDiv}
\end{pspicture}

\psset{plotpoints=241,plotstyle=line,yMaxValue=5}
\begin{pspicture}[showgrid=bottom](-2,-5)(4,5)
    \psplot[linecolor=red]{-2}{4}{1 x myDiv}
    \psplot[linecolor=blue]{-2}{4}{-1 x myDiv}
\end{pspicture}

\end{document}

enter image description here

  • Is 1e30 the maximum value allowed in PS? – kiss my armpit Aug 24 '12 at 8:44
  • 1
    that is the value accepted by all PS levels – user2478 Aug 24 '12 at 8:47
  • If we gradually increase plotpoints for the last pspicture with plotstyle=line, the graph is actually still asymmetric for the first several plotpoints and it reaches the steady state later. – kiss my armpit Aug 24 '12 at 9:04
  • sure, only the |y| < yMaxValue are plotted, there is no interpolation – user2478 Aug 24 '12 at 9:26
  • I still don't understand why plotstyle=dots always produces a symmetric result but plotstyle=line does not. In my mental model, plotstyle=line should be symmetric as well if it uses the same dots as plotstyle=dots does. – kiss my armpit Aug 24 '12 at 9:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.