[pstricks] Suggestion for psgraph
Alan Ristow
ristow at ece.gatech.edu
Fri Jul 30 22:15:35 CEST 2004
Hi all,
As I was converting some of my graphs to psgraph I realized that with
certain data sets I needed \psclip to prevent my plots from running
outside the borders of the axes. I had built this in to my old way of
plotting data, but it is not a part of \psgraph. Accordingly, I modified
a local copy of \psgraph at i and \endpsgraph. My modifications are below;
I've pasted the entire routine, but really the only place I've made
changes are on the last line of \psgraph at i and the first line of
\endpsgraph. It could easily be extended so the use of \psclip can be
turned on/off by a parameter key.
Obviously the \psclip and \endpsclip commands can be issued within the
\psgraph environment, but I thought it might be a useful feature to put
inside psgraph. Thoughts? Comments? Are you tired of me messing with
psgraph yet, Herbert? :-)
Alan
\def\psgraph at i[#1](#2,#3)(#4,#5)#6#7{%
% options | minX | minY | maxX | maxY | Length x-axis | length y-axis%
\begingroup%
\pst at dimo=#4\p@\advance\pst at dimo by -#2\p@ % delta x
\pst at divide{#6}{\pst at dimo}\pst at tempa
\pst at xunit=\pst at tempa\p@%
%
\pst at dimo=#5\p@\advance\pst at dimo by -#3\p@ % delta y
\pst at divide{#7}{\pst at dimo}\pst at tempa%
\pst at yunit=\pst at tempa\p@%
%
\pst at dima=#2\pst at xunit \advance\pst at dima by \psk at llx%
\pst at dimb=#3\pst at yunit \advance\pst at dimb by \psk at lly%
\pst at dimc=#4\pst at xunit \advance\pst at dimc by \psk at urx%
\pst at dimd=#5\pst at yunit \advance\pst at dimd by \psk at ury%
\pspicture(\pst at dima,\pst at dimb)(\pst at dimc,\pst at dimd)%
\psset{xunit=\pst at xunit,yunit=\pst at yunit}%
\psaxes[#1](0,0)(#2,#3)(#4,#5)%
\ifx\psk at xAxisLabel\@empty\else%
\ifx\psk at xAxisLabelPos\@empty%
\uput[0](#4,0){\psk at xAxisLabel}%
\uput[90](0,#5){\psk at yAxisLabel}%
\else%
\rput(\psk at xAxisLabelPos){\psk at xAxisLabel}%
\rput{90}(\psk at yAxisLabelPos){\psk at yAxisLabel}%
\fi%
\fi %
\psclip{\psframe[linestyle=none](#2,#3)(#4,#5)}%
}
\def\endpsgraph{%
\endpsclip
\endpspicture%
\endgroup%
}
More information about the PSTricks
mailing list