# Strange behaviour drawing lines with multido and trigonometric functions

I'm trying to produce Taylor diagrams to compare statistically data sets. Here is the code as a first approach to such diagram.

\begin{pspicture}(-1,-1)(5.75,5.75)
\psaxes(0,0)(4,4)
\begin{psclip}{\pswedge(0,0){4}{0}{90}}
\multido{\ra=1+1}{4}{%
\pscircle[linewidth=1pt](2.6;0){\ra}%
\psplot[algebraic]{0}{\ra}{sqrt(\ra*\ra - x*x)}}
\multido{\rx=0.0+0.1}{10}{%
\pstVerb{/pen \rx\space 1 div ACOS def}
\psplot[linecolor=green]{0}{4}{x pen TAN mul}}
\end{psclip}
\multido{\ry=0.0+0.1}{10}{%
\rput{! \ry\space 1 div ACOS RadtoDeg}(! \ry\space 4 mul 16 \ry\space 4 mul
dup mul sub sqrt){\psPrintValue{\ry\space 1 div ACOS RadtoDeg}}}
\end{pspicture}


The problem is with the second loop that draws the green lines giving:

Note the two green lines close to 45 degrees (should only be one). The slopes are from angles corresponding to a 1/10 division of the x axis. Surely the code can be written more easily or in a more compact way but I would appreciate to know why this code produces such anomaly or what can be wrong.

• Welcome to TeX.SX! Please don't post code fragments. Instead, put your fragments into a complete compilable document that shows the problem. Sep 11 '17 at 21:19

Use a simple \psline for it:

\documentclass[pstricks]{standalone}
\usepackage{pst-plot,pst-math}
\usepackage{auto-pst-pdf}

\begin{document}

\begin{pspicture}(-1,-1)(5.75,5.75)
\psaxes(4,4)
\begin{psclip}{\pswedge(0,0){4}{0}{90}}
\multido{\ia=1+1}{4}{%
\pscircle[linewidth=1pt](2.6;0){\ia}%
\psplot[algebraic]{0}{\ia}{sqrt(\ia*\ia - x*x)}}
\multido{\rx=0.0+0.1}{10}{%
\psline[linecolor=green](!4 \rx\space ACOS RadtoDeg PtoC)
}
\end{psclip}
\multido{\ry=0.0+0.1}{10}{%
\rput{! \ry\space ACOS RadtoDeg}(! \ry\space 4 mul 16 \ry\space 4 mul
dup mul sub sqrt){\psPrintValue{\ry\space ACOS RadtoDeg}}}
\end{pspicture}

\end{document}


An alternative solution:

\begin{pspicture}(-1,-1)(5.75,5.75)
\psaxes(4,4)
\begin{psclip}{\pswedge(0,0){4}{0}{90}}
\multido{\ia=1+1}{4}{%
\pscircle[linewidth=1pt](2.6;0){\ia}%
\psarc(0,0){\ia}{0}{90}
}
\multido{\rx=0.0+0.1}{10}{%
\psline[linecolor=green](!4 \rx\space ACOS RadtoDeg PtoC)
}
\end{psclip}
\multido{\ry=0.0+0.1}{10}{%
\rput{! \ry\space ACOS RadtoDeg}(!4.1 \ry\space ACOS RadtoDeg 1 sub PtoC){%

• @user1259970: PtoC stands for a transforming operator that transforms Polar r Θ to Rectangular x y. Note that Θ must be in degrees. Sep 12 '17 at 17:25
• @user1259970: \psplot{0}{4}{\rx\space ACOS RadtoDeg tan x mul} is the same with psplot. You have a problem with your definition and angle 45 degrees.