[pstricks] Graphing function containing a parameter

Poul Riis Poul.Riis at skolekom.dk
Sat Sep 17 23:43:05 CEST 2005


The tex-file below works fine... sometimes... - and sometimes it does not!
If I change the parameter k to 0.5 it crashes even if 0.4973 and many
other values are OK.
If I change the documentclass to 'article' it crashes.
Furthermore, I get the following (non-fatal) error message:
Package xkeyval Error: `hatchsepinc' undefined in families `,pstricks-add'.

Well, I admit that I'm a poor programmer and that this is my first
primitive version of something that could be made much more elegant....

Yours
Poul Riis


%\listfiles
%\documentclass{article}
\documentclass{scrartcl}
 \usepackage{inputenc}
 \usepackage[T1]{fontenc}
\usepackage[danish]{babel}
%\usepackage[svgnames]{xcolor}
\usepackage{pstricks-add}



\pagestyle{empty}
\topmargin=-0.5cm
\textwidth=17cm
\textheight=26cm
\hoffset=-1cm
\parindent=0cm


%plot the graph of f(x) from xmin to xmax and put a label with the name of
the parameter and its value shifted (x_labelshift,y_labelshift) pointing
to a point on the graph with x-coordinate x_arrowpos



\newcommand{\plotfunctionwithoneparameter}[9]{%
\SpecialCoor
\pstVerb{/#4 #5 def%
/f { #4 mul sin } def%
/g { sin #4 add} def%
  }%
\psset{linecolor=#9}%
\psplot[plotpoints=100]{#2}{#3}{x #1}%
\pnode(!#6 #6 #1){Q}%
\rput[tr](!#6 #7 add #6 #1 #8
add){\rnode{P}{\color{#9}\psframebox[linecolor=#9]{$#4=#5$}}}%{\psframebox{C=\C}}
\ncarc[nodesep=2pt,linecolor=#9]{->}{P}{Q}%
}

\begin{document}
\begin{figure}[!h]
\centering
\psset{xunit=0.2mm,yunit=2.5cm}
\begin{pspicture}(0,-1)(360,2)
\psaxes[Dx=60,Dy=0.5,linewidth=1pt,labels=all,ticksize=-3pt
0]{->}(0,0)(0,-1)(360,2)
%\plotfunctionwithoneparameter {function name}{xmin}{xmax}{parameter
name}{parameter value}{x_arrowpos}{x_labelshift}{y_labelshift}{color}
\plotfunctionwithoneparameter{f}{0}{360}{z}{2}{60}{50}{1.2}{red}
\plotfunctionwithoneparameter{g}{0}{360}{k}{0.25}{150}{50}{1.2}{green}
%\plotfunctionwithoneparameter{0}{360}{k}{0.5}{240}{50}{1.2}{green}
\end{pspicture}
\caption{Graphing functions containing a parameter...}
\end{figure}
\end{document}






More information about the PSTricks mailing list