[pstricks] psgraph for non-integral axis lengths
Alan Ristow
ristow at ece.gatech.edu
Wed Sep 8 16:46:16 CEST 2004
Hi,
The psgraph macro has worked very well for me when the lengths of my
axes are whole numbers. For small axes, however, it has had problems.
Below I have a minimal example that illustrates the problems for a
y-axis of length 0.4. If I am not mistaken, this is expected behavior
resulting from the use of a non-integral divisor in \pst at divide (or,
more accurately, the limited fixed-point arithmetic capabilities of
TeX).
What I would like to know is: (1) Am I correct about this being the
expected behavior? (2) I can partially override psgraph's calculation of
\pst at xunit and \pst at yunit (see example 2 below), but is there a way to
completely override it? (3) Is my workaround using \pstScalePoints (see
example 3 below) the most expedient way to address this issue, or am I
missing something simpler?
I confess I haven't done an exhaustive search of the pstricks-add
documentation or www.pstricks.de, but it might be helpful to add an
example of how best to handle a situation like this to one or both of
them.
Alan
\documentclass{article}
\usepackage{pstricks}%
\usepackage{pstricks-add}%
\usepackage{filecontents}%
\begin{filecontents*}{test.d}
0.0 0.2
1.0 0.35
2.0 0.38
3.0 0.22
4.0 0.15
5.0 0.21
\end{filecontents*}
\pagestyle{empty}
\begin{document}
% Example 1. Grid shows where frame borders and axis labels *should*
% be placed, but axis is clearly longer than it should it be in the
% y-direction.
\begin{figure}[h]
\psgrid[xunit=0.8in,yunit=0.5in,griddots=10,gridlabels=0,%
gridcolor=gray,subgriddiv=0](5,4)%
\begin{psgraph}[axesstyle=frame,tickstyle=bottom,Oy=0.0,Dy=0.1,%
xyLabel={\small}](0,0)(5,0.4){4in}{2in}%
\readdata{\data}{test.d}%
\listplot{\data}%
\end{psgraph}
\end{figure}
% Example 2. By adding yunit=5in to the psgraph options, the frame is
% drawn correctly. However, the data are clearly plotted using an
% incorrect yunit value.
\begin{figure}[h]
\psgrid[xunit=0.8in,yunit=0.5in,griddots=10,gridlabels=0,%
gridcolor=gray,subgriddiv=0](5,4)%
\begin{psgraph}[yunit=5in,axesstyle=frame,tickstyle=bottom,Oy=0.0,Dy=0.1,%
xyLabel={\small}](0,0)(5,0.4){4in}{2in}%
\readdata{\data}{test.d}%
\listplot{\data}%
\end{psgraph}
\end{figure}
% Example 3. By changing the y-coordinate specification to 4 instead
% of 0.4, adding dy=1 to the options list, and scaling the y data by
% a factor of 10, the entire plot is drawn correctly.
\begin{figure}[h]
\psgrid[xunit=0.8in,yunit=0.5in,griddots=10,gridlabels=0,%
gridcolor=gray,subgriddiv=0](5,4)%
\begin{psgraph}[axesstyle=frame,tickstyle=bottom,Oy=0.0,Dy=0.1,%
dy=1,xyLabel={\small}](0,0)(5,4){4in}{2in}%
\pstScalePoints(1,10){}{}%
\readdata{\data}{test.d}%
\listplot{\data}%
\end{psgraph}
\end{figure}
\end{document}
More information about the PSTricks
mailing list