Help on pstricks (and bug in "The LaTeX Graphics Companion"?)
Denis Girou
Denis.Girou at idris.fr
Mon Dec 20 20:26:06 CET 1999
-----------------------------------------------------------------------------
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.
>>>>> "Antonio.Leitao" == Antonio Leitao <aml at gia.ist.utl.pt> writes:
Antonio.Leitao> Hi,
Antonio.Leitao> I'm trying to plot some data using pstricks. So far, I'm using the
Antonio.Leitao> data plotting functions available. Unfortunately, the axes are
Antonio.Leitao> labelled automatically by pstricks, and I would like to have some
Antonio.Leitao> control over that.
Antonio.Leitao> According to "The LaTeX Graphics Companion" (p. 132), "no provision is
Antonio.Leitao> made for supplying specific labels for axis tick points".
Antonio.Leitao> On the other hand, it is also referred (p. 165) that the macros
Antonio.Leitao> \psxlabel and \psylabel can be redefined to set the font and size of
Antonio.Leitao> the labels. There's also an example of this possibility:
Antonio.Leitao> \renewcommand{psxlabel}[1]{{\tiny #1}}
Antonio.Leitao> Unfortunately, the example doesn't work. I remembered vaguely that
Antonio.Leitao> the usual sintax of renewcommand should be
Antonio.Leitao> \renewcommand{\psxlabel}[1]{{\tiny #1}}
Antonio.Leitao> ^
Antonio.Leitao> but this didn't work either, with TeX complaining that \psxlabel is
Antonio.Leitao> undefined.
Antonio.Leitao> I went to the pstricks source and found that psxlabel and psylabel do
Antonio.Leitao> not exist, but there exists pshlabel and psvlabel.
If you want to work deeply with LGC, print the errata list for it:
CTAN/macros/latex/base/grphcomp.err
The last problem is also pointed in the errata list of the PSTricks
documentation (this is inside the "obsolete" subdirectory, as the
documentation is still the one of the version 0.93 plus Beta material of 1994):
CTAN/graphics/pstricks/obsolete/doc/pst-doc.err
Antonio.Leitao> I'm thinking that the last two macros could be used as hooks to change
Antonio.Leitao> the labels for axis tick points. My idea is to provide a table that
Antonio.Leitao> equates ticks with labels, for example, by saying that on tick 1 I
Antonio.Leitao> want the label 'January', on tick 2 'February', etc. The macro
Antonio.Leitao> pshlabel could then be defined as:
Antonio.Leitao> \renewcommand{\pshlabel}[1]{{\getlabelfortick{#1}}}
Antonio.Leitao> The macro getlabelfortick would just "return" the label appropriate
Antonio.Leitao> for each tick. It's just a table lookup in a table previously
Antonio.Leitao> defined.
Antonio.Leitao> Better yet, we could provide two arguments for getlabelfortick. The
Antonio.Leitao> first one is the tick number and the second one is something to
Antonio.Leitao> "return" in case the table didn't specify anything for that tick number.
Antonio.Leitao> This is were I stop. If TeX could be extended in Scheme, C, Pascal or
Antonio.Leitao> some other "simple" language, I could do it myself, but unfortunately
Antonio.Leitao> it isn't. Is there anyone out there that could guide me in achiving
Antonio.Leitao> this? Or is there a simple solution?
Antonio.Leitao> Thanks in advance,
Antonio.Leitao> António Leitão.
For more sophisticated definitions of labels, see for instance the second
example in: http://www.tug.org/ListsArchives/pstricks/msg00353.html
But for what you are looking for, you must proceed in another way. You can
do this, for instance, using the macros from Zhuhan Jiang to manipulate
arrays, according of what we can do in some classic programming languages.
These macros are between lines 344 to 483 of the `formlett' package
(CTAN/macros/generic/formlett.sty). You can also found them extracted in:
http://tug.org/applications/PSTricks/macros/arrayjob.sty
Using it, you can simply write:
\documentclass[a4paper]{article}
\usepackage{arrayjob}
\usepackage{multido}
\usepackage{pst-plot}
\setlength{\parindent}{0cm}
\pagestyle{empty}
\begin{document}
\newarray{\Months}
\readarray{Months}{January & February & Mars & April & May & June &
July & August & September & October & November & December}
\newarray{\ShortMonths}
\readarray{ShortMonths}{Jan & Feb & Mar & Apr & May & &
& & Sep & Oct & Nov & Dec}
\begingroup
\psset{unit=1.1}
\begin{pspicture}(-0.5,-0.5)(13,5)
\psaxes[labels=y]{->}(13,5)
\multido{\iMonth=1+1}{12}{%
\checkMonths(\iMonth)%
\rput[B](\iMonth,-0.3){\tiny\cachedata}}
\end{pspicture}
\endgroup
\vspace{1cm}
\begin{pspicture}(-0.5,-0.5)(13,5)
\psaxes[labels=y]{->}(13,5)
\multido{\iMonth=1+2}{6}{%
\checkMonths(\iMonth)%
\rput[B](\iMonth,-0.5){\small\cachedata}}
\end{pspicture}
\vspace{1cm}
\begin{pspicture}(-0.5,-0.5)(6.5,5)
\psaxes[dx=0.5,labels=y]{->}(6.5,5)
\multido{\iMonth=1+1,\nPos=0.5+0.5}{12}{%
\checkShortMonths(\iMonth)%
\ifx\cachedata\space
\rput[B](\nPos,-0.4){\scriptsize\textbf{?}}
\else
\rput[B](\nPos,-0.4){\scriptsize\cachedata}
\fi}
\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