4

I am using pst-plot to visualize data sets in linear x and logarithmic y scale. The data set should be plotted by connecting all points with a solid line style. This all works fine by using \pstScalePoints(1,1){}{log} as long as there is no point in the data set with (x_i, y_i=0). The behavior I want to achieve is that such points should not be plotted at all and the line connecting all points is then disconnected at that point (that is, there are lines connecting points at x_1 up to x_(i-1), no line from x_(i-1) to x_(i+1), and again lines from x_(i+1) to x_n). This is for example the default behavior in MATLAB. By googling I found the following way to put points with y=0 outside the figure but the connecting lines are still shown: \pstScalePoints(1,1){}{dup 0 eq { pop -1.e30 }{ log } ifelse}. Thanks for you help!

Requested minimal example:

\documentclass{article}
\pagestyle{empty}   

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

\begin{document}

\begin{pspicture}[showgrid=false](0,0)(10,10) 
    \savedata{\mydata}[{{0,0.01},{1, 0.02},{2, 0.00},{3, 0.02},{4, 0.02}}]
    \pstScalePoints(1,1){}{dup 0 eq { pop -1.e30 }{ log } ifelse}
    %\pstScalePoints(1,1){}{ dup 0 eq { pop pop }{ log } ifelse}
    \begin{psgraph}(0,-3)(4,0){4.0cm}{4.0cm}%
        \listplot[linestyle=solid, showpoints=false]{\mydata}
    \end{psgraph}%
\end{pspicture}

\end{document}
  • 1
    Could you mock up an example using pst-plot that does not ignore these requirements? That way the community has something to work with. – Werner Jan 30 '14 at 22:23
  • I added an example that shows the behavior. – TriSSSe Jan 30 '14 at 22:35
  • Torbjørn T. recalls that ignoring out-of-bound values is a built-in feature of pgfplots – Hugo Raguet Apr 24 '17 at 9:43
2

try

\pstScalePoints(1,1){}{ dup 0 eq { pop pop }{ log } ifelse}
| improve this answer | |
  • Thank you for your comment. I tried it but epstool threw an error Error: /rangecheck in --log--. Unfortunately I cannot decipher what the line is doing so I am not able to try and modify it myself. – TriSSSe Jan 30 '14 at 22:43
  • I guess that doesn't work, because you pop off a point from the stack but the number of coordinates for the looping was determined before that. – Christoph Jan 31 '14 at 0:22
  • @Christian: it can be done by redefining \pst@def{PreparePoints}. But I suppose it is less work using a script and modifying the data list. – user2478 Jan 31 '14 at 8:08
  • @Herbert. Thanks again for your input. Since it does not seem trivial, I should probably let this question open until someone finds the time to implement it? Modifying the data list is what I am doing now. However, simply deleting the problematic points does not give the desired result (the line is not disconnected then). – TriSSSe Jan 31 '14 at 20:00

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.