1

Case 0 uses \fnpnodes and case 1 uses \curvepnodes to create nodes based on the given function(s).

\def\method#1{%
    \ifcase#1
        \fnpnodes[plotpoints=8]{1}{8}{\f[x]}{P}
        \psxTick(/dx \pst@number\pst@dimb\space def dx 4 mul 1 add){x_j}
    \or 
        \curvepnodes[plotpoints=8]{1}{8}{t|\f[t]}{P}    
        \psxTick(dt 4 mul 1 add){x_j}
    \fi}

I have known that dt is the increment step of \curvepnodes. Now I am looking for the increment step of \fnpnodes. I tried using /dx \pst@number\pst@dimb\space def dx but it does not seem to work.

\documentclass[pstricks,border=12pt]{standalone}
\usepackage{pst-plot,pst-node}
\psset
{
    algebraic,
    ticks=none,
    labels=none,
    plotpoints=100,
}

\def\f[#1]{sin(3*#1)/2+#1/3+1}

\makeatletter
\def\method#1{%
    \ifcase#1
        \fnpnodes[plotpoints=8]{1}{8}{\f[x]}{P}
        \psxTick(/dx \pst@number\pst@dimb\space def dx 4 mul 1 add){x_j}
    \or 
        \curvepnodes[plotpoints=8]{1}{8}{t|\f[t]}{P}    
        \psxTick(dt 4 mul 1 add){x_j}
    \fi}
\makeatother

\begin{document}    

\begin{psgraph}(0,0)(-.5,-.5)(9.5,5){12cm}{!}
    \method{1} % \method{0} does not work!
    \multido{\iL=0+1,\iR=1+1}{\Pnodecount}{\pspolygon[fillstyle=solid,fillcolor=cyan!15](P\iL|0,0)(P\iL)(P\iR)(P\iR|0,0)}
    \psplot[linecolor=cyan!75!blue]{0}{9}{\f[x]}
    %\psxTick(N-P4.x){x_j} recommended
\end{psgraph}

\end{document}

enter image description here

What is the increment step of \fnpnodes?

1

\fnpnodes doesn't define an increment step on Postscript level, but the calculations are done on TeX-level. So you must do the calculations yourself with (x1 - x0)/(plotpoints - 1) if you need the step:

\fnpnodes[plotpoints=8]{1}{8}{\f[x]}{P}
\psxTick(8 1 sub 7 div 4 mul 1 add){x_j}

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.