STATISTICA







STATISTICA BASIC Program Caseplot.stb

[Graph] 
{ This program will make a line graph of the values in selected cases for selected variables of the data file.

A maximum of 100 cases can be plotted in a single plot (adjust maxcase if necessary).

Program written, modified, or edited at StatSoft, Inc.
}

randomaccess;
NoDataFileVariableNames;
	dim range(2);

	maxcase:=100;
	redim x(nvars);
	redim y(nvars);
	redim jlist(nvars);


{select range of cases to plot}
	range(1):=1;range(2):=1;
	if DisplayNumericInputBox ('Select Range of Cases',
	  'From case:|To case:', range)=0 then stop;
	iflag:=0;
	if range(2)-range(1)<0 then iflag:=1;
	if (range(1)<1) or (range(2)<1) then iflag:=1;
	if (range(1)>ncases) or (range(2)>ncases) then iflag:=2;
	if iflag=1 then begin
	  DisplayMessageBox (MB_ICONSTOP, 'Invalid Case Range',
	   'You have selected an invalid range of case numbers.');
	  stop;
	end else if iflag=2 then begin;
	  DisplayMessageBox (MB_ICONSTOP, 'Invalid Case Range',
	   'You have selected an invalid range of case numbers (there are not enough cases
in the data file).');
	  stop;
	end;
	nplot:=range(2)-range(1)+1;
	if nplot>maxcase then begin
	  DisplayMessageBox (MB_ICONSTOP, 'Too Many Cases',
	   'Select fewer cases to plot.');
	  stop;
	end;

{select variables to plot}
	kname$:='';
	if SelectVariables1 ('Select Variables',
	   2, nvars, jlist, nrows, 'Variables:')=0 then stop;

{fill x range and make variable names}
	j:=1;
	for i:=1 to nvars do begin
	 if i=jlist(j) then begin;
	  x(j):=j;
	  varnam$:=varnam$+VarName(i)+'|';
	  j:=j+1;
	 end;
	end;

{ make the line graph}
	for iplot:=1 to nplot do begin
	 for i:=1 to nrows do y(i):=data(range(1)+iplot-1,jlist(i));
	 if iplot=1 then begin
	  graph:=NewGraph (LINEPLOT,
	   'Plot of Values for Selected Cases',
	   'Value', 'Variable', nrows, x, y);
	   if nrows<=28 then
	     GraphSetScaleTextLabels (graph, AX_X, nrows, x, varnam$)
	   else
	     GraphSetScaling (graph, AX_X, SCALING_MANUAL_0, -.5, nrows+.5, 1);
	   GraphSetScaleTickmarks (graph, AX_X, ON, ?MajorSize, OFF, ?MinorSize,
		?MinorCount);
	   GraphSetPlotName (graph, iplot, CaseName(range(1)+iplot-1), '');
	  end
	  else begin
	   GraphAddPlot (graph, LINEPLOT,
	     CaseName (range(1)+iplot-1),
	     nrows, x, y) ;
	  end;
	  GraphSetPlotPointStyle (graph, iplot, ON, ?Pattern, ?Size, ?Color);
 	end;
Back to List of Programs



[StatSoft]
2300 East 14th Street, Tulsa, OK 74104
Phone: (918) 749-1119; Fax: (918) 749-2217

[StatSoft]e-mail: info@statsoft.com

©Copyright StatSoft, Inc., 1984-2004.
StatSoft, StatSoft logo, STATISTICA, SEWSS, SEDAS, Data Miner, SEPATH and GTrees are trademarks of StatSoft, Inc.