Lollipop Plots Using PSTricks
Denis Girou
Denis.Girou at idris.fr
Thu Jan 6 20:49:44 CET 2000
-----------------------------------------------------------------------------
This is the PSTricks mailing list, devoted to discussions about computational
graphics in (La)TeX using the PSTricks package from Timothy van Zandt.
For help using this mailing list, see instructions at the end of message.
-----------------------------------------------------------------------------
The following message is a courtesy copy of an article
that has been posted to comp.text.tex as well.
>>>>> "Monson.Hayes" == mhh3 <mhh3 at eedsp.gatech.edu> writes:
Monson.Hayes> I would like to generate a "lollipop" plot as one often does in plotting
Monson.Hayes> discrete-time signals. These look like,
Monson.Hayes> OOO O
Monson.Hayes> O | | | O |
Monson.Hayes> | | | | | |
Monson.Hayes> --------
Monson.Hayes> What I would like to do is read in an array of numbers using \dataplot,
Monson.Hayes> and have it generate a plot like this. Although \dataplot would
Monson.Hayes> generate
Monson.Hayes> the "circles" at the appropriate points, it does not generate the
Monson.Hayes> vertical
Monson.Hayes> lines connecting them to the x-axis. I am wondering if anyone has
Monson.Hayes> modified
Monson.Hayes> pst-plot.tex to do this, or can tell me how to make the modifications.
Monson.Hayes> I do not know the postscript language. Thanks.
To obtain plots like:
OOO O
O ||| | O
| ||| | |
---------------
|
O
you must effectively define some internal TeX and PostScript macros,
as such result is not provided by existing functionalities. Here is
one way to do that:
\documentclass[a4paper]{article}
\usepackage{pst-plot}
\makeatletter
% D.G. addition begin - Jan. 6, 2000
\let\beginplot at LineToXAxis\beginplot at line
\def\endplot at LineToXAxis{\psLineToXAxis at ii}
\let\beginqp at LineToXAxis\beginqp at line
\let\doqp at LineToXAxis\doqp at line
\let\endqp at LineToXAxis\endqp at line
\let\testqp at LineToXAxis\testqp at line
% Adapted from \psline at ii
\def\psLineToXAxis at ii{%
% D.G. modification begin - Jan. 6, 2000
%\addto at pscode{\pst at cp \psline at iii \tx at Line}%
\addto at pscode{\pst at cp \psline at iii \tx at LineToXAxis}%
% D.G. modification end
\end at OpenObj}
\def\tx at LineToXAxis{LineToXAxis }
% Adapted from Line
\pst at def{LineToXAxis}<{%
NArray
n 0 eq not
{ n 1 eq { 0 0 /n 2 def } if
ArrowA
/n n 2 sub def
% D.G. modification begin - Jan. 6, 2000
% n { Lineto } repeat
CP 2 copy moveto pop 0 Lineto
n { 2 copy moveto pop 0 Lineto } repeat
% D.G. modification end
CP
4 2 roll
ArrowB
% D.G. modification begin - Jan. 6, 2000
2 copy moveto pop 0
% D.G. modification end
L
pop pop } if}>
% D.G. addition end
\makeatother
\pagestyle{empty}
\begin{document}
\savedata{\Data}[{{(1,2),(3,3),(4,-1),(5,3),(7,3),(8,-2)}}]
\begin{pspicture}(0,-3)(9,4)
\dataplot[plotstyle=LineToXAxis,linestyle=dotted,
showpoints=true,dotstyle=o,dotsize=0.4]{\Data}
\psaxes{<->}(0,0)(0,-3)(9,4)
\end{pspicture}
\end{document}
Denis Girou
--
--------------------------------------------------------------------------
Institut du Développement et des Ressources en Informatique Scientifique |
Centre National de la Recherche Scientifique |
Bâtiment 506 - B.P. 167 - 91403 Orsay Cedex - France |
--------------------------------------------------------------------------
-----------------------------------------------------------------------------
The list interface (subscription, information, access to the archives) is on:
http://www.tug.org/cgi-bin/lwgate/pstricks
Otherway to unsubscribe, send mail to pstricks-request at mail.tug.org
with a blank subject and in body the line unsubscribe <email-address>
-----------------------------------------------------------------------------
More information about the PSTricks
mailing list