* see comments at end-of-file program define gr3 version 2.1 if substr("%_1",1,1)=="," | "%_1"=="" { _3drshow %_* exit } capture conf var _vy _vyy _vx if _rc==0 { #delimit ; di in red "3d graph data in memory; use " in wh "restore" in red " first or do not specify varlist" ; #delimit cr ; exit 198 } _3ddflts mac def _varlist "req ex min(3) max(3)" mac def _if "opt" mac def _in "opt" mac def _options "Rot(int %D3rot) Elev(int %D3elev) Symbol(string) *" parse "%_*" if "%_symbol"=="" { mac def _symbol "o" } else if substr("%_symbol",1,1)=="[" & substr("%_symbol",-1,1)=="]" { parse "%_symbol", parse("[] ") confirm var %_2 mac def _keep "%_2" } parse "%_varlist", parse(" ") _3dsvusr capture { /* begin break-key capture */ if "%_if`%_in"!="" { keep %_if %_in } _3dmkdta %_1 %_2 %_3 %_keep _3drproj %_rot %_elev mac def D3vnames "%_1 %_2 %_3" if "%D3shad"=="on" { _3dshad } _3drshow, sym(%_symbol) %_options #delimit ; di in gr _n " note: The converted data has been left in memory." _n " Type '" in wh "restore" in gr "'to obtain your original data." _n " Use '" in wh "gr3" in gr "' to redisplay graph." ; #delimit cr exit } mac def _rc = _rc /* error-abort */ restore exit %_rc end exit /* gr3: general routine for 3d scatter gr3 [xvar yvar zvar] [, options] If varlist not specified, taken as request to redisplay last graph. This is handled by calling _3drshow. Otherwise, request to handle this graph. See _3drshow for list of options. */ /* 3d graphic routines Copyright (c) 1991 by C.R.C. 1640 Fifth Street Santa Monica, California 90401 1-800-STATAPC */ /* Command Summary: Top Level: gr3 make a 3-d scatterplot restore retrieve user data (see explanation below) gr3save save 3d data gr3use use 3d data gr3set set defaults gr3q query defaults Middle Level: _3dproj make a projection _3drshow reshow last 3d scatterplot Low Level: _3ddflts set defaults to default values _3dmkdta make dtaset containing scaled _x _y _z; add axis _3drproj reproject at specified angles _3dax0 add axis through (0,0,0) to data _3daxmin add axis through (min,min,min) to data _3daxout add "outline" axis to data _3daxtbl add "table" axis to data _3dmnmx rescale variable to range [0,1] _3ddflts set default values in macros _3dsvusr save user data set (also see restore) Global macros used: D3vnames names of variables graphed D3rot default value of rotation D3elev default value of elevation D3tilt default value of tilt (always 0) D3shad on or off (default off) D3lrot rotation of current graph D3lelev elevation of current graph D3ltilt tilt of current graph (always 0) D3_LFN Last S_FN (for re-using data) Notes: These routines create working data sets, all named _XXX.dta. These should no be removed while you are using the gr3 routines. You may erase the data sets freely between times, since this file recreates necessary data sets. Description of 3d data set: _x _y _z contain rescaled (min=0, max=1) variables to be graphed _Type . if original data 2 if axis information 3 if shadow information _vy _vx Projection of _x _y _z _vyy Projection of axis (_vyy _vx) _vyl Projection of labeling (_vyl, _vx) _name names to be printed at (_vyl, _vx) _vybase Projection of (_x,_y,0) (_vybase _vx) _shadow only if shadow information, projection of (_x,0,_z) (_shadow _vx) */