Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

the following code snippet doesn't work as expected

\documentclass{article}

\usepackage{pstricks,pst-plot}

\pagestyle{empty}
\thispagestyle{empty}

\begin{document}

    \begin{pspicture}(10,10)

        \psplot{0}{10}{%
        5 x le { x } if 
    }

    \end{pspicture}

\end{document}

Especially with regard to the PostScript-code

 5 x le { x } if

Simple postscripts without conditional executions or loops work fine. I have the sense that i might have to escape the curly braces, but escaping them with a slash doesn't work either.

Maybe someone of you experts can me help to solve my little problem!?

Let the wisdom be with you and best regards

share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

You don't have to escape the braces, they are correctly passed to the DVI file. However, psplot expects the function to leave a value on the operand stack for each x. The expression

5 x le { x } if

doesn't create any value if the condition evaluates to false. Thus, you should replace it with some kind of ifelse construct instead, e.g. something like

5 x le {x} {0} ifelse
share|improve this answer
    
Thanks a lot for your fast reply! You solved my problem... –  user1146332 May 1 '12 at 17:35
    
I'm glad to hear you could solve your issue. If this answer was helpful to you, please think about accepting it. –  Martin May 3 '12 at 18:45
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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