plotScatterLineFitPredInts.m 880 B

123456789101112131415161718192021222324
  1. function [hFig, hAx, hScatter, hLine, hPatch] = plotScatterLineFitPredInts(x, y)
  2. [xSorted, sortInd] = sort(x);
  3. lineFit = fit(xSorted', y(sortInd)', 'poly1');
  4. confIntType = 'functional';
  5. confIntSimultaneous = 'on';
  6. confLevelArray = [.85, 0.95, 0.99];
  7. hFig = createFullScreenFig;
  8. hAx = gca;
  9. hold on;
  10. lineColor = [.9 0.4 0.7];
  11. patchColor = [.9 0.4 0.7];
  12. patchAlpha = 0.2;
  13. for iLevel = confLevelArray
  14. predInt = range(predint(lineFit, xSorted, iLevel, confIntType, confIntSimultaneous), 2) / 2;
  15. [hLine, hPatch] = plotErrorPatch(hAx, xSorted, lineFit(xSorted), predInt, lineColor, patchColor, patchAlpha);
  16. % shadedErrorBar(xSorted, lineFit(xSorted), predInt, {'Color', patchColor}, patchAlpha);
  17. % plot(xSorted, smooth(xSorted, y(sortInd), 0.5, 'rloess'))
  18. end
  19. hScatter = scatter(xSorted, y(sortInd), 50, 'filled', 'MarkerFaceAlpha', 0.2);
  20. end