[pstricks] Re: PSTricks pst-3dplot question

Herbert Voss Herbert.Voss at alumni.TU-Berlin.DE
Mon Sep 15 22:04:37 CEST 2003


Jonathan Dentch schrieb:
> I would like to plot a surface with data from a file using pst-3dplot.
>  The x data runs from 100 to 260.    The y data runs from 0 to 12. The
> z data runs from 0.0 to 1.0.  Note that z is a function of x and y.
> 
> What should the dimensions be?

this is on the to do list, that the three axes can
have its own dimension...
For now you have to modify the dataplot macro. In this example
I use the following data file and test case, where only the
two lines with %%%%%%%%%%%% are important, they should be
easy to understand. Now the three coordinates are relativ
to 0..1.

If you have a mathematical function
then use pstPlotThreeD and modify \pst at def{ScalePointsThreeD}
in the same way than \def\dataplotThreeD at ii#1{%

Herbert


100 0 0
120 1 0.1
130 2 0.2
150 3 0.3
180 4 0.5
200 6 0.7
220 7 0.8
240 10 0.9
260 12 1




\documentclass[11pt,a4paper]{article}
\usepackage{pst-3dplot}
\psset{subgriddiv=0,griddots=10,gridlabels=7pt}
\makeatletter
\def\dataplotThreeD at ii#1{%
   \@nameuse{beginplot@\psplotstyle}%
     \addto at pscode{%
       /Alpha \psk at ThreeDplot@Alpha\space def
       /Beta \psk at ThreeDplot@Beta\space def
       /Dx { /D { Dy } def } def
       /Dy { /D { Dz } def } def
       /Dz {                     % now we have x y z
         3 -1 roll               % y z x
         260.0 div               % 0 ... 1 %%%%%%%%%%%%
         dup                     % y z x x
         neg Alpha cos mul       % y z x (x)
         4 -1 roll               % z x (x) y
         12.0 div                % 0 ... 1 %%%%%%%%%%%%
         dup                     % z x (x) y y
         5 1 roll                % y z x (x) y
         Alpha sin mul add \pst at number\psxunit mul % y z x (x2)
         4 1 roll                % (x2) y z x
         Alpha sin mul           % (x2) y z (x)
         3 -1 roll               % (x2) z (x) y
         Alpha cos mul add neg Beta sin mul % (x2) z (x)
         exch                    % (x2) (x) z
         Beta cos mul add \pst at number\psyunit mul % (x2) (y2)
         Do /D { Dx } def } def
       /D { /D { Dx } def } def
       /Do {
         \@nameuse{beginqp@\psplotstyle}%
         /Do { \@nameuse{doqp@\psplotstyle}} def
       } def}%
     #1%
     \addto at pscode{D}%
   \@nameuse{endqp@\psplotstyle}%
}
\makeatother
\begin{document}

\vspace{1cm}
\begin{center}
\begin{pspicture}(-6,-2)(6,8)
     \psgrid
     \psset{Alpha=45,Beta=15,xunit=5cm,yunit=5cm}
     \pstThreeDCoor[%
         xMin=-0.1,xMax=1.25,%
         yMin=-0.1,yMax=1.25,%
         zMin=-0.1,zMax=1.25]
     \readdata{\data}{test2.data}
     \typeout{\data}%only for controlling data input
     \dataplotThreeD[plotstyle=dots,dotsize=0.25]{\data}
\end{pspicture}
\end{center}

\end{document}





More information about the PSTricks mailing list