[pstricks] help for writing a macro

Herbert Voss Herbert.Voss at FU-Berlin.DE
Sat Oct 29 10:03:08 CEST 2016


Am 28.10.2016 um 19:41 schrieb Germain Boyer:

> There is a little problem when xunit and yunit are different.
> The solution is changing the unit in the argument and changing the
> coordinates of the point like in this example :

Use it this way:

\documentclass{scrartcl}
\usepackage{pst-plot}

\makeatletter
\def\psdotsx{\@ifnextchar[{\psdotsx at i}{\psdotsx at i[]}}
\def\psdotsx at i[#1](#2){%
   \def\psdotsx at para{#1}
   \begingroup
   \psset{#1}\psdotsx at ii(#2)%
}% end of  \def\psdotsx at i
\def\psdotsx at ii(#1){%
   \pnode(#1){thenode}\psdotsx at iii
   \@ifnextchar({\psdotsx at ii}{\endgroup}
}% end of  \def\psdotsx at ii
\def\psdotsx at iii{%
   \pnode([nodesep=1.5mm,angle=45,\psdotsx at para]thenode){thenodea}%
   \multido{\ia=0+90 , \ib=1+1}{4}{%
	\psRelNode[angle=\ia,xunit=1cm,yunit=1cm](thenode)(thenodea){1}{thenode\ib}
	\psline(thenode)(thenode\ib)%
   }% end of \multido
}% end of  \def\psdotsx at iii
\makeatother
\begin{document}
	
%\def\xmin{-9.6} \def\xmax{150.6} \def\ymin{-9.6} \def\ymax{200.6}
\psset{xunit=0.1cm,yunit=0.05cm,arrowinset=0,arrowscale=1.25}
\begin{pspicture}(-11,-11)(150.6,200.6)
\psaxes[linewidth=1pt,xticksize=0 200,yticksize=0 150,tickcolor=black!20,
   Dx=10,Dy=10]{->}(150.6,200.6)[$v_i$,-90][$d_i$,180]
\psaxes[labels=none,axesstyle=frame,ticksize=-3pt,
   tickwidth=0.75pt,Dx=10,Dy=10](150,200)
\psdotsx[yunit=2,angle=45,linewidth=0.75pt]%
   (! 20 \space 3.5 2 div)%
   (! 43\space 20.5 2 div)%
   (! 62 \space 35.9 2 div)%
   (! 80 \space 67.8 2 div)%
   (! 98 \space 101.2 2 div)%
   (! 115 \space 135.8 2 div)%
   (! 130 \space 168.5 2 div)%
%
\psdotsx[angle=45,linewidth=0.75pt,linecolor=red](20,20)
\psdotsx[angle=45,linewidth=0.75pt](! 20 \space 30 2 div)
\psdotsx[angle=0,linewidth=0.75pt,linecolor=red](20,40)
%
\psplot[algebraic,linewidth=0.5pt]{0}{140}{(257/30000)*x^2+(43/200)*x-(317/75)}
\end{pspicture}

\end{document}

only \psRelNode is modified

Herbert



More information about the PSTricks mailing list