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

			title ('Observed')

	subplot(2,4,2)
		plot(wavevector,(calcconcs'*calcabs)');
			xlabel ('wavelength');
			ylabel ('absorbance');
			axis ([xminimum xmaximum min(yminimum) max(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);

			tmp_obsdata=size(obsdata);%another matlab hack
			tmp_spex=size(spex);%another matlab hack

			obstrace=obsdata(:,floor(tmp_obsdata(2)/3))./max(obsdata(:,floor(tmp_obsdata(2)/3)));
			calctrace=spex(:,floor(tmp_spex(2)/3))./max(spex(:,floor(tmp_spex(2)/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');
			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')
end
