[pstricks] How to show a specific point of a function's curve?

Jean-Côme Charpentier jean-come.charpentier at wanadoo.fr
Mon Jan 24 10:19:01 CET 2011


Le 23/01/2011 19:11, Denis Bitouzé a écrit :
> Hello,

   Hello young padawan!

> let say we have a curve of a function:

   Ok. Let say.

> [code for f(x) = x^2/10]
>
> What would be the best way to show the point of the curve (with a qdisk
> on the point and two parallel lines for its x- and y-values) just by
> specifying its x-value?

   I'm not sure that my solution is the best way. It uses pst-node (and 
infix-RPN if you want to specify function with algebraic notation).

\documentclass{article}
\usepackage{pst-plot}
\usepackage{pstricks-add}
%%%
\usepackage{pst-node}
\usepackage{infix-RPN} % in order to translate f(x)
                        % alebraic -> Reverse Polish
\newcommand\PWL[3][]{% PWL = Point With Lines
   % #1 = (optionnel) argument for lines
   % #2 = f(x)
   % #3 = x value
     \infixtoRPN{#2}%
     \pnode(!#3 /x #3 def \RPN){Px} % (x,f(x))
     \psline[#1](!0 /x #3 def \RPN)(Px)
     \psline[#1](#3,0)(Px)
}
%%%
\psset{algebraic=true}
\begin{document}
\begin{psgraph}(0,0)(5,3){6cm}{!}
   \psplot{0}{5}{x^2/10}
   \PWL{x^2/10}{2}
   \PWL[linecolor=red,linestyle=dashed]{x^2/10}{4}
\end{psgraph}
\end{document}


> Thanks in anticipation.

   You're welcome my roudoudou :-)

   Jean-Côme Charpentier


More information about the PSTricks mailing list