function plotresults(obsdata, timevector,wavevector, calcconcs,calcabs, principalcomponents,rms,cutoff,maxcut)
	xminimum=cutoff; %min(wavevector);
	xmaximum=maxcut; %max(wavevector);
	yminimum=-0.1;min(min(obsdata));
	ymaximum=1;max(max(obsdata));
	
	subplot(2,4,1)
		plot(wavevector,obsdata);
			xlabel ("wavelength");
			ylabel ("absorbance");
            axis ([xminimum xmaximum yminimum ymaximum]);
#			axis ([min(wavevector) max(wavevector)]);

			title ("Observed")

	subplot(2,4,2)
		plot(wavevector,(calcconcs'*calcabs)');
			xlabel ("wavelength");
			ylabel ("absorbance");
			axis ([xminimum xmaximum yminimum ymaximum]);
#			axis ([min(wavevector) max(wavevector)]);
			title ("Calculated")
	
	subplot(2,4,3)
		plot(wavevector',rms');
			xlabel("Wavelength");
			ylabel("Residual");
			title("Residuals")

	subplot(2,4,4)
			spex=(calcconcs'*calcabs);
			obstrace=obsdata(:,floor(columns(obsdata)/3))./max(obsdata(:,floor(columns(obsdata)/3)));
			calctrace=spex(:,floor(columns(spex)/3))./max(spex(:,floor(columns(spex)/3)));		
		plot(timevector,[obstrace calctrace 10*(obstrace-calctrace)] );
			xlabel("time (s)");
			ylabel("Absorbance");
			title("Absorbance as a function of select lambdas")

	subplot(2,4,5)
		plot(wavevector,calcabs');
			axis ([xminimum xmaximum yminimum ymaximum]);
			xlabel ("Wavelength");
			ylabel ("absorbance");
			title("Calculated rawdata")

	subplot(2,4,6)
		semilogx(timevector,calcconcs');
			xlabel ("time");
			ylabel ("concentration");
			title("Calculated concentrations")

	subplot(2,4,7)
		plot(timevector,calcconcs');
			xlabel ("time");
			ylabel ("concentration");
			title("Calculated concentrations")

	subplot(2,4,8)
		plot(principalcomponents(:,1),principalcomponents(:,2:3),'+'); 
			axis([-0.05 10.05 max(principalcomponents(:,2)-0.01) 1.0005]);
			ylabel("Cumulative variance");
			xlabel("Number of components");
			title("Principcal component analysis")
endfunction
