[pstricks] psplot, own plotstyle?
Herbert Voss
LaTeX at zedat.fu-berlin.de
Fri May 18 08:05:20 CEST 2007
Ludwig Meyerhoff wrote:
> I would like to have horizontal lines from a plotted cosine to the
> y-axis to show the increasing density of the values with equidistant angles.
>
> To plot the cosine is not the problem, but the horizontal lines is!
>
> On the examples on http://tug.org/PSTricks/main.cgi?file=examples I have
> found something similar to what I am looking for, but the lines are
> vertical and not horizontal (http://tug.org/PSTricks/Examples/line0.tex).
>
> >From the example code I can see an own plotstyle was defined, but I do
> not understand the Postscript code (honestly, I already have some
> problems understanding the introducing TeX-defines).
>
>
> Maybe some one can help me out with an appropriate definition?
>
\documentclass[a4paper]{article}
\usepackage{pst-plot}
\makeatletter
\let\beginplot at LineToYAxis\beginplot at line
\def\endplot at LineToYAxis{\psLineToYAxis at ii}
\let\beginqp at LineToYAxis\beginqp at line
\let\doqp at LineToYAxis\doqp at line
\let\endqp at LineToYAxis\endqp at line
\let\testqp at LineToYAxis\testqp at line
%
\def\psLineToYAxis at ii{%
\addto at pscode{\pst at cp \psline at iii \tx at LineToYAxis}%
\end at OpenObj}
%
\def\tx at LineToYAxis{LineToYAxis }
%
% Adapted from Line
\pst at def{LineToYAxis}<{%
NArray
n 0 eq not {
n 1 eq { 0 0 /n 2 def } if
0 0 moveto
/n n 2 sub def
CP 2 copy moveto exch pop exch 0 Lineto
n { 2 copy moveto exch pop 0 exch Lineto } repeat
CP 4 2 roll
ArrowB
2 copy moveto exch pop 0 exch L
pop pop
} if }>
\makeatother
\pagestyle{empty}
\begin{document}
\psset{xunit=0.0333cm,yunit=2.5cm}
\begin{pspicture}(0,-1.2)(400,1.2)
\psline{->}(0,0)(390,0)
\psline{->}(0,-1.1)(0,1.1)
\psplot[plotstyle=LineToYAxis,linestyle=dashed,plotpoints=50,
showpoints=true,dotstyle=o,dotsize=0.2]{0}{360}{x cos}
\end{pspicture}
\end{document}
Herbert
More information about the PSTricks
mailing list