MathGroup Archive 1992

[Date Index] [Thread Index] [Author Index]

Search the Archive

Package for Dot-Dash scater plots

  • To: mathgroup at yoda.physics.unc.edu
  • Subject: Package for Dot-Dash scater plots
  • From: Gossett <gossett at bethel.edu>
  • Date: Sat, 1 Aug 1992 17:19:42 -0500

BeginPackage["ScatterPlot`"]

DotDash::usage = "DotDash[data] produces a dot-dash scatter plot, as defined by Edward Tufte in `The Visual Display of Quantitative Information'.
Examples: DotDash[{{2,5},{2.1,6},{2,5.5},{3,6}}], DotDash[Table[{Random[],Random[]},{i,25}]]"

(* This package may be freely used for non-commercial purposes.
   
                   Copyright July 1992
		   
                   Dr. Eric Gossett
                   Bethel College
                   3900 Bethel Drive
                   St. Paul, MN 55112
                   gossett at bethel.edu
		   
   Version 1.0
*)

Begin["`Private`"]
Unprotect[DotDash]
Off[General::spell1]

xMargin[xvals_,ymin_,yinc_] := Module[{dashes={},i},
  For[i=1,i<=Length[xvals],i++,
      dashes = Append[dashes,
        Line[{{xvals[[i]],ymin-4 yinc},
              {xvals[[i]],ymin-2 yinc}}]]];
   Return[dashes]
]

yMargin[yvals_,xmin_,xinc_] := Module[{dashes={},i},
  For[i=1,i<=Length[yvals],i++,
      dashes = Append[dashes,
        Line[{{xmin-4 xinc,yvals[[i]]},
              {xmin-2 xinc,yvals[[i]]}}]]];
   Return[dashes]
]

DotDash[data_] := Module[{xvals,yvals,xt,yt,xrange,
      yrange,xmin,xmax,ymin,ymax,xmargin,ymargin,labels},

    xvals=Transpose[data][[1]];
    yvals=Transpose[data][[2]];
    xmin=Min[xvals];
    xmax=Max[xvals];
    ymin=Min[yvals];
    ymax=Max[yvals];
    xrange=xmax-xmin;
    yrange=ymax-ymin;
    xt = .025/GoldenRatio xrange;
    yt = .025 yrange;
    xmargin = xMargin[xvals,ymin,yt];
    ymargin = yMargin[yvals,xmin,xt]; 
    labels=Graphics[
              Text[ToString[xmin],{xmin,ymin-9yt},{-1,0}],
              Text["xmin",{xmin,ymin-6yt},{-1,0}],
              Text[ToString[xmax],{xmax,ymin-9yt},{1,0}],
              Text["xmax",{xmax,ymin-6yt},{1,0}],
              Text[ToString[ymin],{xmin-6xt,ymin},{1,0}],
              Text["ymin",{xmin-6xt,ymin+3yt},{1,0}],
              Text[ToString[ymax],{xmin-6xt,ymax},{1,0}],
              Text["ymax",{xmin-6xt,ymax+3yt},{1,0}]
            ];
    Show[ListPlot[data,Axes->False,PlotStyle->PointSize[.01],
           PlotRange->{{xmin-xt,xmax+xt},{ymin-yt,ymax+yt}},
           DisplayFunction->Identity],
         Graphics[{Thickness[.001],xmargin,ymargin}],
         labels,PlotRange->All,
         DisplayFunction->$DisplayFunction]
  ] /; (MatrixQ[data] && (Dimensions[data][[2]] == 2) )
   
On[General::spell1];
End[]
Protect[DotDash]
EndPackage[]





  • Prev by Date: Colors/GrayLevel
  • Next by Date: Numerical Analysis Materials?
  • Previous by thread: Colors/GrayLevel
  • Next by thread: Numerical Analysis Materials?