Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • surface_view: A 150-plus-line piece of code brimming with Geek spirit

    I would like to thank Professor Choonjoo Lee , who has continually amazed me with his Stata programming over the past few days. He used coordinate transformations to fix overlapping bars in 2D, and he use the exact same approach to brute-force a 3D projection onto Stata's strictly 2D canvas. I don't fully understand his codes. But, Cool!

    Code:
    clear
    set obs 160
    generate double x = 2*runiform()-1
    generate double y = 2*runiform()-1
    generate double outcome = 10 + 2*x - 1.5*y + 3*x*y - 1.2*x^2 + .6*y^2 + 2*rnormal()
    regress outcome c.x##c.y c.x#c.x c.y#c.y
    estimates save fitted_model, replace
    scalar critical = invttail(e(df_r), .025)
    save training_data, replace
    
    clear
    set obs 441
    generate int ix = mod(_n-1,21)
    generate int iy = floor((_n-1)/21)
    generate double x = (ix-10)/10
    generate double y = (iy-10)/10
    predict double mu, xb
    predict double se_mean, stdp
    generate double lower = mu - critical*se_mean
    generate double upper = mu + critical*se_mean
    generate byte selected = inlist(ix,5,10,15) & inlist(iy,5,10,15)
    assert lower < mu & mu < upper
    isid x y
    save prediction_grid, replace
    
    * Orthographic projection prototype. It draws with official twoway primitives.
    * Not part of pseudobars; no hidden-surface removal or interactive Stata camera.
    * Normalized Z = (mean-10)/5; the same transformation applies to every endpoint.
    capture program drop surface_view
    program define surface_view
        syntax, AZimuth(real) ELevation(real) NAME(name) TITLE(string) ///
            [ASPECT(real 1) ZStretch(real 1)]
        preserve
        local a = `azimuth'*_pi/180
        local e = `elevation'*_pi/180
        generate double zn = `zstretch'*(mu-10)/5
        generate double u = cos(`a')*x - sin(`a')*y
        generate double v = -sin(`e')*(sin(`a')*x+cos(`a')*y) + cos(`e')*zn
        generate double depth = cos(`e')*(sin(`a')*x+cos(`a')*y) + sin(`e')*zn
        generate double vl = -sin(`e')*(sin(`a')*x+cos(`a')*y) + cos(`e')*`zstretch'*(lower-10)/5
        generate double vh = -sin(`e')*(sin(`a')*x+cos(`a')*y) + cos(`e')*`zstretch'*(upper-10)/5
        * A rotation preserves 3D length in the normalized coordinate system.
        assert abs(u^2+v^2+depth^2 - (x^2+y^2+zn^2)) < 1e-10
        * The projected interval midpoint stays on its projected mean.
        assert abs((vl+vh)/2-v) < 1e-12
        * Inverse rotation recovers the normalized data coordinates.
        generate double q = -sin(`e')*v + cos(`e')*depth
        assert abs(cos(`a')*u + sin(`a')*q - x) < 1e-12
        assert abs(-sin(`a')*u + cos(`a')*q - y) < 1e-12
        assert abs(cos(`e')*v + sin(`e')*depth - zn) < 1e-12
        if `elevation' == 90 & `azimuth' == 0 {
            assert abs(u-x)<1e-12
            assert abs(v+y)<1e-12
        }
        export delimited x y mu lower upper u v depth vl vh using layout_`name'.csv, replace
        local mesh
        forvalues j=0(2)20 {
            local mesh `"`mesh' (line v u if iy==`j', sort(ix) lcolor("70 115 145") lwidth(vthin))"'
            local mesh `"`mesh' (line v u if ix==`j', sort(iy) lcolor("70 115 145") lwidth(vthin))"'
        }
        * Axis endpoints and ticks are projected by the identical transform.
        local axes
        local texts
        local ox -1
        local oy -1
        local oz = `zstretch'*(2-10)/5
        local ou = cos(`a')*`ox'-sin(`a')*`oy'
        local ov = -sin(`e')*(sin(`a')*`ox'+cos(`a')*`oy')+cos(`e')*`oz'
        foreach axis in x y z {
            local ex = cond("`axis'"=="x", 1, -1)
            local ey = cond("`axis'"=="y", 1, -1)
            local ez = cond("`axis'"=="z", `zstretch'*(16-10)/5, `oz')
            local eu = cos(`a')*`ex'-sin(`a')*`ey'
            local ev = -sin(`e')*(sin(`a')*`ex'+cos(`a')*`ey')+cos(`e')*`ez'
            local axes `"`axes' (pci `ov' `ou' `ev' `eu', lcolor(gs6) lwidth(thin))"'
            local label = upper("`axis'")
            if "`axis'"=="z" local label "Mean"
            local texts `"`texts' text(`ev' `eu' "`label'", place(ne) size(small))"'
            local ticks 0 1
            if "`axis'"=="z" local ticks 2 6 10 14 16
            foreach t of local ticks {
                local tx = cond("`axis'"=="x", `t', -1)
                local ty = cond("`axis'"=="y", `t', -1)
                local tz = cond("`axis'"=="z", `zstretch'*(`t'-10)/5, `oz')
                local tu = cos(`a')*`tx'-sin(`a')*`ty'
                local tv = -sin(`e')*(sin(`a')*`tx'+cos(`a')*`ty')+cos(`e')*`tz'
                local texts `"`texts' text(`tv' `tu' "`t'", place(sw) size(vsmall))"'
            }
        }
        twoway `mesh' `axes' ///
            (pcspike vl u vh u if selected, lcolor(maroon) lwidth(medthick)) ///
            (scatter v u if selected, mcolor(maroon) msize(vsmall)), ///
            `texts' title("`title'") ///
            subtitle("Azimuth `azimuth'; elevation `elevation'; Z stretch `zstretch'", size(small)) ///
            note("Red: nine means and pointwise 95% CIs. Wireframe: all depths visible.", size(vsmall)) ///
            xscale(off range(-2.2 2.2)) yscale(off range(-2.2 2.2)) ///
            xlabel(-2.2 2.2, nogrid) ylabel(-2.2 2.2, nogrid) ///
            xtitle("") ytitle("") legend(off) aspectratio(`aspect') ///
            scheme(s2color) graphregion(color(white)) name(`name', replace)
        restore
    end
    
    surface_view, azimuth(35) elevation(25) name(view_a) title("coordinate projection")
    Code:
    capture ssc install surface
    surface x y mu
    Click image for larger version

Name:	view_a.png
Views:	1
Size:	219.4 KB
ID:	1787646
    Click image for larger version

Name:	surface.png
Views:	1
Size:	322.4 KB
ID:	1787647



  • #2
    Chen Samulsion

    Chen, this one is for you: another application of pseudobars!

    Click image for larger version

Name:	stata_wave.png
Views:	1
Size:	166.1 KB
ID:	1787653

    Comment


    • #3
      Let me do some practical work using Choonjoo Lee's powerful surface_view program. First block of codes is -surface_view.ado- that modified from Professor Choonjo's code (which I posted in #1). Hope the rewrite avoid bugs (or mistakes) as far as possible.

      Code:
      *! surface_view v2.2.0 - Pure Wireframe (No scatter points)
      
      program define surface_view
          version 16.0
          syntax varlist(min=3 max=5 numeric) [if] [in] , ///
              AZimuth(real) ELevation(real) NAME(name) ///
              [TITLE(string) ASPECT(real 1) ZStretch(real 1) ///
               XLAB(string) YLAB(string) ZLAB(string)]
      
          tokenize `varlist'
          local xvar "`1'"
          local yvar "`2'"
          local zvar "`3'"
          local lci "`4'"
          local uci "`5'"
      
          marksample touse
          markout `touse' `xvar' `yvar' `zvar'
      
          local a = `azimuth' * _pi / 180
          local e = `elevation' * _pi / 180
          local ca = cos(`a')
          local sa = sin(`a')
          local ce = cos(`e')
          local se = sin(`e')
      
          preserve
          qui keep if `touse'
      
          // Data mapping
          qui summarize `xvar', meanonly
          local xmin = r(min)
          local xmax = r(max)
          local xr = `xmax' - `xmin'
          if `xr' == 0 local xr = 1
          qui generate double vx = 2 * (`xvar' - `xmin') / `xr'
      
          qui summarize `yvar', meanonly
          local ymin = r(min)
          local ymax = r(max)
          local yr = `ymax' - `ymin'
          if `yr' == 0 local yr = 1
          qui generate double vy = 2 * (`yvar' - `ymin') / `yr'
      
          qui summarize `zvar', meanonly
          local zmin = r(min)
          local zmax = r(max)
          local zrange = `zmax' - `zmin'
          if `zrange' == 0 local zrange = 1
          qui generate double vz = 2 * (`zvar' - `zmin') / `zrange'
      
          // Projection
          qui generate double zn = `zstretch' * vz
          qui generate double u = `ca' * vx - `sa' * vy
          qui generate double v = -`se' * (`sa' * vx + `ca' * vy) + `ce' * zn
      
          // Confidence intervals
          local has_ci = 0
          if "`lci'" != "" & "`uci'" != "" {
              local has_ci = 1
              qui generate double vzl = `zstretch' * 2 * (`lci' - `zmin') / `zrange'
              qui generate double vzu = `zstretch' * 2 * (`uci' - `zmin') / `zrange'
              qui generate double vl = -`se' * (`sa' * vx + `ca' * vy) + `ce' * vzl
              qui generate double vh = -`se' * (`sa' * vx + `ca' * vy) + `ce' * vzu
          }
      
          // Wireframe
          egen ix = group(`xvar')
          egen iy = group(`yvar')
          qui summarize ix, meanonly
          local nx = r(max)
          qui summarize iy, meanonly
          local ny = r(max)
      
          local mesh ""
          forvalues j = 1/`ny' {
              local mesh `"`mesh' (line v u if iy==`j', sort(ix) lcolor("70 115 145") lwidth(vthin))"'
          }
          forvalues i = 1/`nx' {
              local mesh `"`mesh' (line v u if ix==`i', sort(iy) lcolor("70 115 145") lwidth(vthin))"'
          }
      
          // Axes
          local axes ""
          local texts ""
          local ox 0
          local oy 0
          local oz 0
          local ou = `ca' * `ox' - `sa' * `oy'
          local ov = -`se' * (`sa' * `ox' + `ca' * `oy') + `ce' * `oz'
      
          foreach axis in x y z {
              if "`axis'" == "x" {
                  local ex 2
                  local ey 0
                  local ez 0
                  local lbl = cond("`xlab'"=="", "X", "`xlab'")
              }
              else if "`axis'" == "y" {
                  local ex 0
                  local ey 2
                  local ez 0
                  local lbl = cond("`ylab'"=="", "Y", "`ylab'")
              }
              else {
                  local ex 0
                  local ey 0
                  local ez 2 * `zstretch'
                  local lbl = cond("`zlab'"=="", "Mean", "`zlab'")
              }
      
              local eu = `ca' * `ex' - `sa' * `ey'
              local ev = -`se' * (`sa' * `ex' + `ca' * `ey') + `ce' * `ez'
              
              local axes `"`axes' (pci `ov' `ou' `ev' `eu', lcolor(gs6) lwidth(thin))"'
              local texts `"`texts' text(`ev' `eu' "`lbl'", place(ne) size(small))"'
              
              local ticks 0 1 2
              if "`axis'" == "z" local ticks 0.4 1.2 2.0 
              foreach t of local ticks {
                  local tx = cond("`axis'"=="x", `t', 0)
                  local ty = cond("`axis'"=="y", `t', 0)
                  local tz = cond("`axis'"=="z", `t' * `zstretch', 0)
                  local tu = `ca' * `tx' - `sa' * `ty'
                  local tv = -`se' * (`sa' * `tx' + `ca' * `ty') + `ce' * `tz'
                  local texts `"`texts' text(`tv' `tu' "`t'", place(sw) size(vsmall))"'
              }
          }
      
          // Boundaries
          qui summarize u
          local umin = r(min)
          local umax = r(max)
          qui summarize v
          local vmin = r(min)
          local vmax = r(max)
      
          local xmin_plot = `umin' - 0.5
          local xmax_plot = `umax' + 0.5
          local ymin_plot = `vmin' - 0.5
          local ymax_plot = `vmax' + 0.5
      
          // Assembling layers (with the scatter points completely removed)
          local ttl = cond("`title'"=="", "Orthographic Surface View", "`title'")
          local plot_cmd `"twoway `mesh' `axes'"'
          
          if `has_ci' == 1 {
              local plot_cmd `"`plot_cmd' (pcspike vl u vh u, lcolor(maroon) lwidth(medthick))"'
          }
      
          `plot_cmd', ///
              `texts' title("`ttl'") ///
              subtitle("Azimuth `azimuth'; elevation `elevation'; Z stretch `zstretch'", size(small)) ///
              note("Wireframe: all depths visible.", size(vsmall)) ///
              xscale(off range(`xmin_plot' `xmax_plot')) yscale(off range(`ymin_plot' `ymax_plot')) ///
              legend(off) aspectratio(`aspect') ///
              scheme(s2color) graphregion(color(white)) ///
              name(`name', replace)
      
          restore
      end
      Code:
      webuse grunfeld
      xtset
      surface_view time company invest, azimuth(35) elevation(25) name(invest) title("Orthographic Surface View of {it:invest}")
      surface_view time company mvalue, azimuth(35) elevation(25) name(mvalue) title("Orthographic Surface View of {it:mvalue}")
      surface_view time company kstock, azimuth(35) elevation(25) name(kstock) title("Orthographic Surface View of {it:kstock}")
      Click image for larger version

Name:	invest.png
Views:	1
Size:	297.3 KB
ID:	1787665


      Click image for larger version

Name:	mvalue.png
Views:	1
Size:	351.1 KB
ID:	1787666
      Click image for larger version

Name:	kstock.png
Views:	1
Size:	313.3 KB
ID:	1787667

      Comment


      • #4
        Chen Samulsion
        Thank you, Chen, for this interesting extension. I tried surface, graph3d and scat3 with the same Grunfeld observations; the comparison is shown below. With the axis ranges and viewing angles adjusted, graph3d produces a very similar wireframe, while scat3 shows the individual observations clearly. In the enhanced panel, I retained the full mesh and added original-unit ticks, highlighted company paths and the 1954 cross-section. The cross-company lines are visual guides, since company IDs are categorical.

        The key settings are below; styling and export commands are omitted. These assume the Grunfeld data are already loaded and the three commands are installed.

        Code:
        sort company year
        
        * surface: ticks in the original units
        surface year company kstock, xlabel(1935 1945 1954) ///
            ylabel(1 5 10) zlabel(1 500 1000 1500 2000 2200)
        
        * graph3d: equal display ranges, using integer grid coordinates
        quietly summarize kstock, meanonly
        generate double H = 171*(kstock-r(min))/(r(max)-r(min))
        generate double X = 9*(year-1935)
        generate double C = 19*(company-1)
        graph3d X H C, wire cuboid scale(85.5) ///
            xangle(25) yangle(35) zangle(0)
        
        * scat3: matching viewing direction, with points and drop lines
        scat3 year company kstock, rotate(-35) elevate(25) axistype(minimum)
        The enhanced panel uses a separate local adaptation of the full-mesh code; its principal additions are original-unit ticks and selected company/year highlights.
        Following Statalist’s guidance on attachments, I have included only the key code here. If there is interest, I would be happy to share the complete code needed to reproduce the comparison through a suitable public link.
        Click image for larger version

Name:	01_configured_comparison.png
Views:	1
Size:	831.7 KB
ID:	1787672

        Comment


        • #5
          Thank you, Choonjoo Lee. I actually compared all three commands you cited above before I posted in #3, in order to ensure that my rewrite of surface_view is correct. The -surface- command cannot adjust the angle—that's a pity. -scat3- (Nick Cox) uses scatters to show individual observations but lacks a surface (literally). I also tried -graphd3d-, and unfortunately it failed. The reason is that I didn't create the necessary variables, i.e., H, X, and C. Overall, I compared what I knew about 3D plots in Stata so far (I should mention -scatter3d- here, which creates 3D scatter plots using HTML5 and CanvasXpress's API), and I found your surface_view to be the most flexible and suitable for me. I also compared it with -panelview-, and for this I set the azimuth to 360. You said:

          Following Statalist's guidance on attachments, I have included only the key code here.
          I didn't know Statalist had this regulation. If you don't mind, I would appreciate it if you could show me your code. In particular, when I posted in #3, I was fully aware that I had set the x-, y-, and z-axis ranges all to [0, 2] rather than to ranges based on the variables' original values. In addition, that piece of code could not set the axis labels. Thank you.

          Comment


          • #6
            Chen Samulsion
            Dear Chen, one image I have in mind is the Earth seen through Superman’s eyes, as he flies around it and views it from different angles. That same curiosity is what draws me to the coordinate-based approach behind pseudobars and our surface-view experiments. I’ve really enjoyed exploring these ideas with you.

            Here is the complete code and a Grunfeld example. The coordinates remain internally normalized to [0,2], while the axis labels show the original values. I have also removed the earlier angle restrictions and made the axes and labels adjust to the viewing direction, including azimuth(360).

            Save the two code blocks as chen_surface.ado and demo_camera.do in the same folder, then run do demo_camera.do from that folder. Thank you for your interest—I’ve really enjoyed exploring these ideas with you.

            Code:
            *! chen_surface 0.2.0 23oct2026
            * Complete, regularly spaced numeric panels. All mesh lines remain visible.
            * Separate sharing version: the earlier comparison files are left intact.
            program define chen_surface, rclass
                version 16.0
                syntax varlist(min=3 max=3 numeric) [if] [in], NAME(name) ///
                    ZRange(numlist min=2 max=2) ZTicks(numlist) XTicks(numlist) ///
                    SLICE(real) [LOGScale HILite(numlist integer max=2) ///
                    XStep(real 1) AZimuth(real 35) ELevation(real 25) ///
                    TITLE(string) XTitle(string) YTitle(string) ZTitle(string) ///
                    LEGENDRows(integer 1)]
                tokenize `varlist'
                local xv `1'
                local pv `2'
                local zv `3'
                local zlo : word 1 of `zrange'
                local zhi : word 2 of `zrange'
                if missing(`zlo',`zhi',`xstep',`azimuth',`elevation') error 198
                if `zhi'<=`zlo' | `xstep'<=0 | `legendrows'<1 error 198
                if "`logscale'"!="" & `zlo'<=0 error 198
                * Equivalent rotations share exactly the same trigonometric arguments.
                local az = mod(mod(`azimuth',360)+360,360)
                local el = mod(mod(`elevation',360)+360,360)
                local ca=cos(`az'*_pi/180)
                local sa=sin(`az'*_pi/180)
                local ce=cos(`el'*_pi/180)
                local se=sin(`el'*_pi/180)
                foreach trig in ca sa ce se {
                    if abs(``trig'')<1e-14 local `trig' 0
                }
                if `"`xtitle'"'=="" local xtitle "`xv'"
                if `"`ytitle'"'=="" local ytitle "`pv'"
                if `"`ztitle'"'=="" local ztitle "`zv'"
                marksample touse
                preserve
                quietly keep if `touse'
                quietly count
                if r(N)==0 error 2000
                local n=r(N)
                isid `pv' `xv'
                tempvar ix ip xx yy zz u v d
                quietly egen long `ix'=group(`xv')
                quietly egen long `ip'=group(`pv')
                quietly summarize `ix', meanonly
                local nx=r(max)
                quietly summarize `ip', meanonly
                local np=r(max)
                if `nx'<2 | `np'<2 error 2001
                if `n'!=`nx'*`np' {
                    display as error "A complete panel grid is required; missing cells must not be bridged."
                    error 459
                }
                bysort `pv' (`xv'): assert abs(`xv'-`xv'[_n-1]-`xstep')<1e-8 if _n>1
                assert inrange(`zv',`zlo',`zhi')
                quietly count if `xv'==`slice'
                if r(N)!=`np' error 198
                quietly summarize `xv', meanonly
                local xmin=r(min)
                local xmax=r(max)
                foreach t of numlist `xticks' {
                    if !inrange(`t',`xmin',`xmax') error 198
                }
                foreach t of numlist `zticks' {
                    if !inrange(`t',`zlo',`zhi') error 198
                }
                * Sort requested numeric tick values before testing their spacing.
                numlist "`xticks'", sort
                local xticks "`r(numlist)'"
                numlist "`zticks'", sort
                local zticks "`r(numlist)'"
                quietly levelsof `pv', local(pticks)
                local z0=`zlo'
                local z1=`zhi'
                if "`logscale'"!="" {
                    local z0=ln(`zlo')
                    local z1=ln(`zhi')
                }
                quietly generate double `xx'=2*(`xv'-`xmin')/(`xmax'-`xmin')
                quietly generate double `yy'=2*(`ip'-1)/(`np'-1)
                quietly generate double `zz'=2*(`zv'-`z0')/(`z1'-`z0')
                if "`logscale'"!="" quietly replace `zz'=2*(ln(`zv')-`z0')/(`z1'-`z0')
                quietly generate double `u'=`ca'*`xx'-`sa'*`yy'
                quietly generate double `v'=-`se'*(`sa'*`xx'+`ca'*`yy')+`ce'*`zz'
                quietly generate double `d'=`ce'*(`sa'*`xx'+`ca'*`yy')+`se'*`zz'
                assert abs(`u'^2+`v'^2+`d'^2-(`xx'^2+`yy'^2+`zz'^2))<1e-10
                assert abs(`ce'*`v'+`se'*`d'-`zz')<1e-12
            
                * Project all eight box corners. The screen bounds follow the camera.
                local umin=.
                local umax=.
                local vmin=.
                local vmax=.
                local zu=.
                local zvbase=.
                foreach bx in 0 2 {
                    foreach by in 0 2 {
                        local bu=`ca'*`bx'-`sa'*`by'
                        local bv=-`se'*(`sa'*`bx'+`ca'*`by')
                        if missing(`zu') | `bu'>`zu'+1e-12 | ///
                            (abs(`bu'-`zu')<1e-12 & `bv'<`zvbase') {
                            local zu=`bu'
                            local zvbase=`bv'
                        }
                        foreach bz in 0 2 {
                            local cv=`bv'+`ce'*`bz'
                            local umin=min(`umin',`bu')
                            local umax=max(`umax',`bu')
                            local vmin=min(`vmin',`cv')
                            local vmax=max(`vmax',`cv')
                        }
                    }
                }
                local uc=`ca'-`sa'
                local vc=-`se'*(`sa'+`ca')+`ce'
                local plots
                local texts
                local count 0
                local notes "Wireframe: all depths visible. Company links are visual guides."
            
                * Reference lines at the last observed time use the same projection.
                foreach t of numlist `zticks' {
                    local h=2*(`t'-`z0')/(`z1'-`z0')
                    if "`logscale'"!="" local h=2*(ln(`t')-`z0')/(`z1'-`z0')
                    local ub=2*`ca'
                    local uf=2*`ca'-2*`sa'
                    local vb=-2*`se'*`sa'+`ce'*`h'
                    local vf=-2*`se'*(`sa'+`ca')+`ce'*`h'
                    local plots `"`plots' (pci `vb' `ub' `vf' `uf', lcolor("218 225 231") lpattern(shortdash) lwidth(vthin))"'
                    local ++count
                }
                forvalues j=1/`nx' {
                    local plots `"`plots' (line `v' `u' if `ix'==`j', sort(`ip') lcolor("140 167 185") lwidth(vthin))"'
                    local ++count
                }
                forvalues j=1/`np' {
                    local plots `"`plots' (line `v' `u' if `ip'==`j', sort(`ix') lcolor("70 115 145") lwidth(thin))"'
                    local ++count
                }
                local plots `"`plots' (line `v' `u' if `xv'==`slice', sort(`ip') lcolor("25 60 83") lwidth(medthick))"'
                local ++count
                local key `"`count' "`slice' cross-section""'
                local hnum 0
                foreach c of local hilite {
                    quietly count if `pv'==`c'
                    if r(N)==0 error 198
                    local ++hnum
                    local col "198 86 33"
                    if `hnum'==2 local col "126 74 146"
                    local plots `"`plots' (line `v' `u' if `pv'==`c', sort(`ix') lcolor("`col'") lwidth(medthick))"'
                    local ++count
                    local key `"`key' `count' "Company `c'""'
                    local plots `"`plots' (scatter `v' `u' if `pv'==`c' & `xv'==`slice', msymbol(O) msize(small) mcolor("`col'"))"'
                    local ++count
                }
            
                * Four base edges. Labels are placed on the outside of selected edges.
                local ux=2*`ca'
                local vx=-2*`se'*`sa'
                local uy=-2*`sa'
                local vy=-2*`se'*`ca'
                local uxy=`ux'+`uy'
                local vxy=`vx'+`vy'
                local plots `"`plots' (pci 0 0 `vx' `ux' `vx' `ux' `vxy' `uxy' `vxy' `uxy' `vy' `uy' `vy' `uy' 0 0, lcolor(gs8) lwidth(thin))"'
                tempname annotations axes
                matrix `axes'=J(3,7,.)
                local axisrow 0
                local nann 0
                foreach axis in x y z {
                    local ++axisrow
                    local su 0
                    local sv 0
                    local shiftu 0
                    local shiftv 0
                    local nu 1
                    local nv 0
                    if "`axis'"=="x" {
                        local du=`ux'
                        local dv=`vx'
                        local shiftu=`uy'
                        local shiftv=`vy'
                        local ticks "`xticks'"
                        local atitle `"`xtitle'"'
                    }
                    if "`axis'"=="y" {
                        local du=`uy'
                        local dv=`vy'
                        local shiftu=`ux'
                        local shiftv=`vx'
                        local ticks "`pticks'"
                        local atitle `"`ytitle'"'
                    }
                    if "`axis'"=="z" {
                        local su=`zu'
                        local sv=`zvbase'
                        local du 0
                        local dv=2*`ce'
                        local ticks "`zticks'"
                        local atitle `"`ztitle'"'
                    }
                    local alen=sqrt((`du')^2+(`dv')^2)
                    local visible_`axis'=(`alen'>1e-10)
                    if "`axis'"!="z" & `alen'>1e-10 {
                        local nu=-`dv'/`alen'
                        local nv=`du'/`alen'
                        local s0=`nu'*(`du'/2-`uc')+`nv'*(`dv'/2-`vc')
                        local s1=`s0'+`nu'*`shiftu'+`nv'*`shiftv'
                        if abs(`s1')>abs(`s0')+1e-12 {
                            local su=`shiftu'
                            local sv=`shiftv'
                            local s0=`s1'
                        }
                        if `s0'<0 {
                            local nu=-`nu'
                            local nv=-`nv'
                        }
                    }
                    matrix `axes'[`axisrow',1]=`su',`sv',`du',`dv',`nu',`nv',`alen'
                    if `alen'<1e-10 {
                        local notes `"`notes' `axis'-axis is edge-on; its scale is not visible."'
                        continue
                    }
                    local eu=`su'+`du'
                    local ev=`sv'+`dv'
                    local plots `"`plots' (pci `sv' `su' `ev' `eu', lcolor(gs8) lwidth(thin))"'
                    local lastu=.
                    local lastv=.
                    local nticks : word count `ticks'
                    local lasttick : word `nticks' of `ticks'
                    local lastf=1
                    if "`axis'"=="x" local lastf=(`lasttick'-`xmin')/(`xmax'-`xmin')
                    if "`axis'"=="z" {
                        local lastf=(`lasttick'-`z0')/(`z1'-`z0')
                        if "`logscale'"!="" local lastf=(ln(`lasttick')-`z0')/(`z1'-`z0')
                    }
                    local index 0
                    local labels_`axis' 0
                    foreach t of numlist `ticks' {
                        local ++index
                        local f=(`t'-`xmin')/(`xmax'-`xmin')
                        local lab = strtrim(string(`t',"%12.0gc"))
                        if "`axis'"=="x" local lab = strtrim(string(`t',"%12.0g"))
                        if "`axis'"=="y" {
                            local f=(`index'-1)/(`np'-1)
                            local lab "C`lab'"
                        }
                        if "`axis'"=="z" {
                            local f=(`t'-`z0')/(`z1'-`z0')
                            if "`logscale'"!="" local f=(ln(`t')-`z0')/(`z1'-`z0')
                        }
                        local pu=`su'+`f'*`du'
                        local pvscreen=`sv'+`f'*`dv'
                        local tu=`pu'+.035*`nu'
                        local tv=`pvscreen'+.035*`nv'
                        local plots `"`plots' (pci `pvscreen' `pu' `tv' `tu', lcolor(gs8) lwidth(thin))"'
                        * Retain tick marks; thin text where rotation compresses a scale.
                        local gapu=.34
                        if "`axis'"=="y" local gapu=.25
                        local gapv=.16
                        local spaced=missing(`lastu') | abs(`pu'-`lastu')>`gapu' | abs(`pvscreen'-`lastv')>`gapv'
                        local endspace=(`index'==`nticks') | abs((`lastf'-`f')*`du')>`gapu' | abs((`lastf'-`f')*`dv')>`gapv'
                        if `alen'<.22 | !`spaced' | (!`endspace' & `index'>1) continue
                        local lastu=`pu'
                        local lastv=`pvscreen'
                        local hw=.033*strlen("`lab'")+.03
                        local hh=.075
                        local support=abs(`nu')*`hw'+abs(`nv')*`hh'
                        local offset=.07+`support'
                        local tu=`pu'+`offset'*`nu'
                        local tv=`pvscreen'+`offset'*`nv'
                        * Separate labels at shared corners, without moving their ticks.
                        local collision 1
                        local tries 0
                        while `collision' & `tries'<80 {
                            local collision 0
                            if `nann'>0 {
                                forvalues k=1/`nann' {
                                    if abs(`tu'-`annotations'[`k',5])<`hw'+`annotations'[`k',7]+.02 & ///
                                        abs(`tv'-`annotations'[`k',6])<`hh'+`annotations'[`k',8]+.02 local collision 1
                                }
                            }
                            if `collision' {
                                local offset=`offset'+.08
                                local tu=`pu'+`offset'*`nu'
                                local tv=`pvscreen'+`offset'*`nv'
                            }
                            local ++tries
                        }
                        if `collision' error 498
                        if `offset'>`support'+.15 {
                            local lu=`pu'+(`offset'-`support'-.03)*`nu'
                            local lv=`pvscreen'+(`offset'-`support'-.03)*`nv'
                            local plots `"`plots' (pci `pvscreen' `pu' `lv' `lu', lcolor(gs12) lwidth(vthin))"'
                        }
                        local texts `"`texts' text(`tv' `tu' "`lab'", place(c) size(vsmall) color(gs5))"'
                        local umin=min(`umin',`tu'-`hw')
                        local umax=max(`umax',`tu'+`hw')
                        local vmin=min(`vmin',`tv'-`hh')
                        local vmax=max(`vmax',`tv'+`hh')
                        matrix `annotations'=nullmat(`annotations') \ (`axisrow',`t',`pu',`pvscreen',`tu',`tv',`hw',`hh')
                        local ++nann
                        local ++labels_`axis'
                    }
                    if `alen'<.22 {
                        local notes `"`notes' `axis'-axis tick labels omitted: compressed view."'
                    }
                    local tu=`su'+.5*`du'+.43*`nu'
                    local tv=`sv'+.5*`dv'+.43*`nv'
                    if "`axis'"=="z" {
                        local tu=`su'+.15
                        local tv=max(`vmax',`sv',`ev')+.25
                    }
                    local hw=.045*strlen(`"`atitle'"')+.06
                    local hh=.12
                    local tnu=`nu'
                    local tnv=`nv'
                    if "`axis'"=="z" {
                        local tnu 0
                        local tnv 1
                    }
                    local collision 1
                    local tries 0
                    while `collision' & `tries'<80 {
                        local collision 0
                        if `nann'>0 {
                            forvalues k=1/`nann' {
                                if abs(`tu'-`annotations'[`k',5])<`hw'+`annotations'[`k',7]+.02 & ///
                                    abs(`tv'-`annotations'[`k',6])<`hh'+`annotations'[`k',8]+.02 local collision 1
                            }
                        }
                        if `collision' {
                            local tu=`tu'+.08*`tnu'
                            local tv=`tv'+.08*`tnv'
                        }
                        local ++tries
                    }
                    if `collision' error 498
                    local texts `"`texts' text(`tv' `tu' "`atitle'", place(c) size(small) color("30 55 75"))"'
                    local umin=min(`umin',`tu'-`hw')
                    local umax=max(`umax',`tu'+`hw')
                    local vmin=min(`vmin',`tv'-`hh')
                    local vmax=max(`vmax',`tv'+`hh')
                    matrix `annotations'=nullmat(`annotations') \ (`axisrow',.,.,.,`tu',`tv',`hw',`hh')
                    local ++nann
                }
                local umin=`umin'-.15
                local umax=`umax'+.15
                local vmin=`vmin'-.15
                local vmax=`vmax'+.15
                local ratio=(`vmax'-`vmin')/(`umax'-`umin')
                tempname geometry
                sort `pv' `xv'
                mkmat `xv' `pv' `zv' `xx' `yy' `zz' `u' `v' `d', matrix(`geometry')
                matrix colnames `geometry'=x panel value nx ny nz u v depth
                matrix colnames `axes'=u0 v0 du dv normal_u normal_v length
                matrix rownames `axes'=x y z
                matrix colnames `annotations'=axis value tick_u tick_v text_u text_v halfwidth halfheight
                twoway `plots', `texts' title(`"`title'"', size(medium)) ///
                    legend(order(`key') rows(`legendrows') size(small) region(lcolor(none)) position(6)) ///
                    note(`"`notes'"', size(vsmall)) ///
                    xscale(off range(`umin' `umax')) yscale(off range(`vmin' `vmax')) ///
                    xlabel(`umin' `umax', nolabels noticks nogrid) ///
                    ylabel(`vmin' `vmax', nolabels noticks nogrid) xtitle("") ytitle("") ///
                    aspectratio(`ratio') graphregion(color(white)) plotregion(margin(zero)) ///
                    scheme(s2color) xsize(10) ysize(8) name(`name', replace) nodraw
                restore
                return scalar N=`n'
                return scalar nx=`nx'
                return scalar npanels=`np'
                return scalar azimuth=`az'
                return scalar elevation=`el'
                return scalar umin=`umin'
                return scalar umax=`umax'
                return scalar vmin=`vmin'
                return scalar vmax=`vmax'
                foreach axis in x y z {
                    return scalar visible_`axis'=`visible_`axis''
                }
                return matrix layout=`geometry'
                return matrix axes=`axes'
                return matrix annotations=`annotations'
            end
            Code:
            * Set Stata's working directory to this folder, then: do demo_camera.do
            * This demonstration replaces the data in memory. Stata 16 or later.
            version 16.0
            clear all
            set more off
            capture mkdir figures
            run chen_surface.ado
            webuse grunfeld, clear
            
            * All coordinates and ticks are calculated within chen_surface.
            * Keep azimuth(360), and use a second oblique view to show depth clearly.
            * The elevation(90) top view remains in test_camera.do and camera_gallery.png.
            local angles "35 25 360 25 90 25 180 25 270 25 315 35"
            local names
            forvalues i=1/6 {
                local aindex=2*`i'-1
                local eindex=2*`i'
                local az : word `aindex' of `angles'
                local el : word `eindex' of `angles'
                chen_surface year company kstock, name(camera`i') ///
                    zrange(0 2500) zticks(0 500 1000 1500 2000 2500) ///
                    xticks(1935 1940 1945 1950 1954) slice(1954) hilite(1 10) ///
                    azimuth(`az') elevation(`el') legendrows(2) ///
                    xtitle("Year") ytitle("Company") ztitle("Capital stock") ///
                    title("Azimuth `az'; elevation `el'")
                graph display camera`i'
                graph save figures/camera`i'.gph, replace
                graph export figures/camera`i'.png, width(1800) replace
                local names `names' camera`i'
            }
            graph combine `names', cols(3) imargin(small) altshrink ///
                graphregion(color(white)) xsize(15) ysize(8) name(camera_examples, replace)
            graph export figures/camera_examples.png, width(3000) replace
            display "CAMERA_DEMO_COMPLETE"
            Click image for larger version

Name:	camera_examples.png
Views:	1
Size:	561.9 KB
ID:	1787676

            Comment


            • #7
              Dear Choonjoo Lee, I was astonished at your coding speed once again.

              That image of Superman flying around the Earth, seeing it from different angles, perfectly captures the essence of what we've been exploring. It's exactly that kind of curiosity—looking at the same data from different perspectives—that makes these coordinate-based approaches so fascinating. I have thoroughly enjoyed our exchange as well.

              Your Superman analogy has suddenly given Stata—a software born in 1985—a touch of science fiction, which I feel it has always lacked.

              The update you've described sounds fantastic. Keeping the coordinates internally normalized to [0,2] while displaying the original values on the axes is a much more elegant and robust solution. And removing the angle restrictions to allow the axes and labels to dynamically adjust to the viewing direction—including full 360-degree azimuth rotation—is exactly the kind of polish that makes a tool genuinely useful. I will rename the command leeview.ado.

              Comment


              • #8
                Dear Chen Samulsion ,

                Thank you! Your great questions are what brought me this far. Perhaps I should write a chenprompt.ado to give credit where it's due.
                P.S. I do have my own little sandbox, but my AI translator deserves a lot of credit too—it has helped me break through the language barrier and enjoy exchanges like this.

                Comment


                • #9
                  Nick Cox mentioned Tufte's The Visual Display of Quantitative Information in another thread. I didn't find any critique of pie charts in it, but I did find a very interesting figure (p. 147). See the figure below. Cited: Philip E. Converse, "Religion and Politics: The 1960 Election," in Angus Campbell, Philip E. Converse, Warren E. Miller, and Donald E. Stokes, Elections and the Political Order (New York, 1966), 102-103. On this page, Tufte described that:
                  The grid that follows presents the data on the surface of the rock; on the sides, the grid is conventional. The two displays compare the effect of religion, taking into account party affiliation, on a person's vote for president in 1956 and in 1960 (when a Catholic ran for president). Note there is no reliable slope associated with religion in 1956, once party is controlled; in 1960, a systematic effect is found. Reading the slopes in the other direction shows the persistent effect of party in both elections.
                  Click image for larger version

Name:	573.png
Views:	1
Size:	1.16 MB
ID:	1788132

                  Comment


                  • #10
                    The passage about pie charts is on p.178 in both editions of Tufte's book. It is brief but damning. See also Jacques Bertin's book there cited.

                    Is each display in #9 so much better than a table or (more to the point) four curves on a flat graph? The book can be retrieved by me from a local library; if the data can be retrieved too, I may try some alternatives. I'd be tempted to plot percents on a logit scale.

                    The 1956 election was essentially Eisenhower (R) versus Stevenson (D). The 1960 election was Kennedy (D) versus Nixon (R). Kennedy was Catholic, which may well help to explain the simpler 1960 pattern. Many readers will know this very well....
                    Last edited by Nick Cox; 15 Nov 2026, 09:32.

                    Comment


                    • #11
                      Using the currently available ANES 1956–1960 panel data, I have reconstructed the two surfaces in Stata. Both years use the same sample of 673 respondents, classified by their 1958 party identification and 1960 religious identification. The height represents the Democratic share of the two-party presidential vote.

                      Unweighted results

                      Each respondent contributes equally to the percentage within their group.

                      Click image for larger version

Name:	converse_comparison_unweighted.png
Views:	1
Size:	429.2 KB
ID:	1788142


                      Weighted results

                      The percentages use the weight supplied in the panel dataset (V600569), so respondents contribute according to their assigned weights. The group definitions and respondents are otherwise identical to those in the unweighted figure.

                      Click image for larger version

Name:	converse_comparison_weighted.png
Views:	1
Size:	419.1 KB
ID:	1788143


                      These are reconstructions from the current data, rather than exact reproductions of the historical figures. The correspondence between the supplied weight and Converse’s original analytical weights has not yet been established. No smoothing has been applied; four cells in each surface contain fewer than ten respondents. The shaded sides and grid lines are visual aids.

                      Comment


                      • #12
                        Dear Choonjoo Lee, that's so cool! I had been looking for the data all this time, and I never expected you'd found it in ANES and reproduced such a beautiful graph so precisely. I'm in awe. Thank you.

                        Comment


                        • #13
                          Code:
                          * Example generated by -dataex-. To install: ssc install dataex
                          clear
                          input byte(V560132 V600657 V600824 V600842 V600843 freq) float perc
                          0 0 1 2 2  1  .0660502
                          0 0 5 2 1  1  .0660502
                          1 0 0 0 2  2  .1321004
                          1 0 0 1 1  2  .1321004
                          1 0 0 2 2  7  .4623514
                          1 0 1 0 1  4  .2642008
                          1 0 1 0 2  4  .2642008
                          1 0 1 1 1 17 1.1228534
                          1 0 1 2 1  9  .5944518
                          1 0 1 2 2 69 4.5574636
                          1 0 5 0 1  1  .0660502
                          1 0 5 0 2  3  .1981506
                          1 0 5 1 1 16 1.0568032
                          1 0 5 1 2  1  .0660502
                          1 0 5 2 1  5   .330251
                          1 0 5 2 2 46  3.038309
                          1 0 9 2 2  1  .0660502
                          2 0 0 0 1  1  .0660502
                          2 0 0 0 2  1  .0660502
                          2 0 0 2 2  5   .330251
                          2 0 1 0 1  2  .1321004
                          2 0 1 0 2  2  .1321004
                          2 0 1 1 1 14  .9247028
                          2 0 1 2 1  5   .330251
                          2 0 1 2 2 51   3.36856
                          2 0 5 0 1  1  .0660502
                          2 0 5 1 1  4  .2642008
                          2 0 5 2 1  1  .0660502
                          2 0 5 2 2  4  .2642008
                          3 0 0 1 1  1  .0660502
                          3 0 0 2 1  1  .0660502
                          3 0 0 2 2  9  .5944518
                          7 0 1 2 1  1  .0660502
                          7 0 1 2 2  1  .0660502
                          9 0 0 2 1  7  .4623514
                          9 0 0 2 2  6  .3963012
                          9 0 1 2 1 14  .9247028
                          9 0 1 2 2 15   .990753
                          9 0 3 2 2  1  .0660502
                          9 0 5 2 1  5   .330251
                          9 0 5 2 2 16 1.0568032
                          9 0 9 2 2  1  .0660502
                          0 1 0 0 2  1  .0660502
                          0 1 0 2 2  2  .1321004
                          0 1 5 1 1  2  .1321004
                          0 1 9 1 1  1  .0660502
                          1 1 0 0 1  1  .0660502
                          1 1 0 0 2  3  .1981506
                          1 1 0 1 1  6  .3963012
                          1 1 0 2 1  2  .1321004
                          1 1 0 2 2 10   .660502
                          1 1 1 0 1  4  .2642008
                          1 1 1 0 2  3  .1981506
                          1 1 1 1 1 12  .7926024
                          1 1 1 1 2  1  .0660502
                          1 1 1 2 1  6  .3963012
                          1 1 1 2 2 55  3.632761
                          1 1 3 2 2  1  .0660502
                          1 1 5 0 1  2  .1321004
                          1 1 5 0 2  6  .3963012
                          1 1 5 1 1 11  .7265522
                          1 1 5 2 1  7  .4623514
                          1 1 5 2 2 54  3.566711
                          1 1 9 2 2  1  .0660502
                          2 1 0 2 2  4  .2642008
                          2 1 1 0 1  1  .0660502
                          2 1 1 0 2  2  .1321004
                          2 1 1 1 1 20  1.321004
                          2 1 1 1 2  1  .0660502
                          2 1 1 2 1  5   .330251
                          2 1 1 2 2 30  1.981506
                          2 1 5 0 1  1  .0660502
                          2 1 5 1 1  3  .1981506
                          2 1 5 2 1  1  .0660502
                          2 1 5 2 2 16 1.0568032
                          2 1 9 2 2  1  .0660502
                          3 1 0 0 2  2  .1321004
                          3 1 0 2 1  2  .1321004
                          3 1 0 2 2  6  .3963012
                          7 1 1 0 2  1  .0660502
                          7 1 5 2 2  1  .0660502
                          9 1 0 2 1  7  .4623514
                          9 1 0 2 2  2  .1321004
                          9 1 1 2 1 11  .7265522
                          9 1 1 2 2 20  1.321004
                          9 1 3 2 2  1  .0660502
                          9 1 5 2 1 10   .660502
                          9 1 5 2 2 20  1.321004
                          9 1 9 2 2  1  .0660502
                          1 2 0 2 1  1  .0660502
                          1 2 0 2 2  2  .1321004
                          1 2 1 0 1  1  .0660502
                          1 2 1 1 1  1  .0660502
                          1 2 1 2 1  1  .0660502
                          1 2 1 2 2 11  .7265522
                          1 2 5 0 2  1  .0660502
                          1 2 5 1 1  3  .1981506
                          1 2 5 2 1  2  .1321004
                          1 2 5 2 2  8  .5284016
                          2 2 0 0 1  2  .1321004
                          end
                          label values V560132 V560132_
                          label def V560132_ 0 "0. NONE", modify
                          label def V560132_ 1 "1. PROTESTANT", modify
                          label def V560132_ 2 "2. ROMAN CATHOLIC", modify
                          label def V560132_ 3 "3. JEWISH", modify
                          label def V560132_ 7 "7. OTHER (INCLUDE HERE EASTERN OR ORTHODO", modify
                          label def V560132_ 9 "9. NA", modify
                          label values V600657 V600657_
                          label def V600657_ 0 "0. STRONG DEMOCRAT", modify
                          label def V600657_ 1 "1. NOT VERY STRONG DEMOCRAT", modify
                          label def V600657_ 2 "2. INDEPENDENT CLOSER TO DEMOCRATS", modify
                          label values V600824 V600824_
                          label def V600824_ 0 "0. INAP", modify
                          label def V600824_ 1 "1. STRONG", modify
                          label def V600824_ 3 "3. SOMEWHAT STRONG", modify
                          label def V600824_ 5 "5. NOT VERY STRONG", modify
                          label def V600824_ 9 "9. NA", modify
                          label values V600842 V600842_
                          label def V600842_ 0 "0. NOT INTERVIEWED IN 1958", modify
                          label def V600842_ 1 "1. INTERVIEWED IN 1958, BUT NOT A MEMBER O", modify
                          label def V600842_ 2 "2. INTERVIEWED IN 1958, AND A MEMBER OF BO", modify
                          label values V600843 V600843_
                          label def V600843_ 1 "1. INTERVIEWED AT LEAST ONE WAVE IN 1960,", modify
                          label def V600843_ 2 "2. INTERVIEWED AT LEAST ONE WAVE IN 1960,", modify
                          label var V560132 "56: YOU PROT,CATH OR JEWIS"
                          label var V600657 "60: RS PARTY ALLEGIANCE"
                          label var V600824 "60: RS RELIGION STRONG"
                          label var V600842 "P 1958 RESPONDENT STATUS"
                          label var V600843 "P 1960 RESPONDENT STATUS"
                          Last edited by Chen Samulsion; 15 Nov 2026, 11:54.

                          Comment


                          • #14
                            Thank you, Chen, and thank you for sharing the data example. One detail that may help when reproducing the surfaces: I used party identification from 1958 (V580360) and religious affiliation and strength from 1960 (V600818 and V600824), following Converse’s description. The height is the Democratic share of the two-party vote within each group, calculated from V560203 and V600767, rather than the group’s percentage of the full sample. Your example appears to contain the latter. My figures are reconstructions from the current data, without the smoothing used in the historical figures.

                            Comment


                            • #15
                              Thank you very much, Choonjoo Lee, I will explore that.
                              Code:
                              . des V580360    V600818    V600824 V560203 V600767
                              
                                  storage    display    value
                              variable name    type    format     label    variable label
                                              
                              V580360    byte    %40.0g     V580360_    58: POLITICAL PARTISANSHIP
                              V600818    float    %9.0g    60: RS CHURCH PREFERENCE
                              V600824    byte    %18.0g     V600824_    60: RS RELIGION STRONG
                              V560203    float    %42.0g     V560203_    56: RS ACTL/INTND PRESL VT
                              V600767    float    %43.0g     V600767_    60: WHM R VTED FR PRES
                              
                              . tab1 V580360 V600818 V600824 V560203 V600767
                              
                              -> tabulation of V580360  
                              
                              58: POLITICAL PARTISANSHIP       Freq.    Percent    Cum.
                                      
                              0. STRONG DEMOCRAT         364    24.04    24.04
                              1. NOT VERY STRONG DEMOCRAT         315    20.81    44.85
                              2. INDEPENDENT CLOSER TO DEMOCRATS          89    5.88    50.73
                              3. INDEPENDENT          99    6.54    57.27
                              4. INDEPENDENT CLOSER TO REPUBLICANS          76    5.02    62.29
                              5. NOT VERY STRONG REPUBLICAN         232    15.32    77.61
                              6. STRONG REPUBLICAN         174    11.49    89.10
                              7. OTHER, MINOR PARTY, OR REFUSED TO SA           4    0.26    89.37
                              8. APOLITICAL          52    3.43    92.80
                              9. NA         109    7.20    100.00
                                      
                              Total       1,514    100.00
                              
                              -> tabulation of V600818  
                              
                              60: RS 
                              CHURCH 
                              PREFERENCE       Freq.     Percent        Cum.
                              
                              0          16        1.06        1.06
                              100          35        2.31        3.37
                              102           3        0.20        3.57
                              109           6        0.40        3.96
                              110         111        7.33       11.29
                              111         122        8.06       19.35
                              112          28        1.85       21.20
                              113           1        0.07       21.27
                              114           6        0.40       21.66
                              115           8        0.53       22.19
                              116          56        3.70       25.89
                              120         223       14.73       40.62
                              121           2        0.13       40.75
                              122           8        0.53       41.28
                              123         295       19.48       60.77
                              124           1        0.07       60.83
                              125          35        2.31       63.14
                              130           1        0.07       63.21
                              131           9        0.59       63.80
                              132           3        0.20       64.00
                              133           1        0.07       64.07
                              135           9        0.59       64.66
                              136          18        1.19       65.85
                              137           3        0.20       66.05
                              138           7        0.46       66.51
                              139           3        0.20       66.71
                              149          20        1.32       68.03
                              150           8        0.53       68.56
                              152           6        0.40       68.96
                              153           4        0.26       69.22
                              154           4        0.26       69.48
                              155           2        0.13       69.62
                              200         312       20.61       90.22
                              300          45        2.97       93.20
                              710           2        0.13       93.33
                              711           1        0.07       93.39
                              721           1        0.07       93.46
                              728           1        0.07       93.53
                              790           9        0.59       94.12
                              991          30        1.98       96.10
                              999          59        3.90      100.00
                              
                              Total       1,514      100.00
                              
                              -> tabulation of V600824  
                              
                              60: RS RELIGION 
                              STRONG       Freq.     Percent        Cum.
                              
                              0. INAP         157       10.37       10.37
                              1. STRONG         787       51.98       62.35
                              3. SOMEWHAT STRONG          10        0.66       63.01
                              5. NOT VERY STRONG         541       35.73       98.75
                              8. DK           1        0.07       98.81
                              9. NA          18        1.19      100.00
                              
                              Total       1,514      100.00
                              
                              -> tabulation of V560203  
                              
                              56: RS ACTL/INTND PRESL VT       Freq.    Percent    Cum.
                                      
                              11. VOTED - DEMOCRATIC         357    23.58    23.58
                              12. VOTED - REPUBLICAN         539    35.60    59.18
                              13. VOTED - OTHER           3    0.20    59.38
                              14. VOTED - REFUSED TO SAY FOR WHOM           7    0.46    59.84
                              21. NON-VOTER - DEMOCRATIC PREFERENCE          78    5.15    64.99
                              22. NON-VOTER - REPUBLICAN PREFERENCE         180    11.89    76.88
                              23. NON-VOTER - OTHER PREFERENCE           1    0.07    76.95
                              24. NON-VOTER - REFUSED TO STATE PREFER           2    0.13    77.08
                              28. NON-VOTER - DK PREFERENCE          27    1.78    78.86
                              30. NON-VOTER - NA PREFERENCE, VOTED BU           1    0.07    78.93
                              99. NONINTERVIEW         319    21.07    100.00
                                      
                              Total       1,514    100.00
                              
                              -> tabulation of V600767  
                              
                              60: WHM R VTED FR PRES       Freq.    Percent    Cum.
                                      
                              10. VOTED - DEMOCRATIC         568    37.52    37.52
                              20. VOTED - REPUBLICAN         581    38.38    75.89
                              30. VOTED - OTHER           8    0.53    76.42
                              40. VOTED - REFUSED TO SAY FOR WHOM           8    0.53    76.95
                              70. NON-VOTER - DEMOCRATIC PREFERENCE         147    9.71    86.66
                              80. NON-VOTER - REPUBLICAN PREFERENCE          84    5.55    92.21
                              97. NON-VOTER - REFUSED TO STATE PREFER           1    0.07    92.27
                              98. NON-VOTER - DK PREFERENCE          27    1.78    94.06
                              99. NON-VOTER - NA PREFERENCE, PRE-ELEC          90    5.94    100.00
                                      
                              Total       1,514    100.00

                              Comment

                              Working...
                              X