From a2138c1f952ef86be7e07c7abe394474deeba337 Mon Sep 17 00:00:00 2001 From: Karthik Chandrashekara Date: Sun, 11 Jul 2021 06:05:59 +0200 Subject: [PATCH] Plots the confidence interval as a shaded region. --- .../+Plotting/plotConfidenceIntervalRegion.m | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 MOT Capture Process Simulation/+Plotting/plotConfidenceIntervalRegion.m diff --git a/MOT Capture Process Simulation/+Plotting/plotConfidenceIntervalRegion.m b/MOT Capture Process Simulation/+Plotting/plotConfidenceIntervalRegion.m new file mode 100644 index 0000000..2769798 --- /dev/null +++ b/MOT Capture Process Simulation/+Plotting/plotConfidenceIntervalRegion.m @@ -0,0 +1,18 @@ +function plotConfidenceIntervalRegion(x, y1, y2) + % draws two lines on a plot and shades the area between those + % lines to indicate confidence interval. + hold on + + X_interpolated = linspace(min(x), max(x), 100); + Y1_interpolated = interp1(x,y1,X_interpolated); + Y2_interpolated = interp1(x,y2,X_interpolated); + + %Plot the line edges + %plot(X_interpolated, Y1_interpolated, 'LineWidth', 0.5, 'LineStyle', '--', 'Color', '#FE1A1A'); + %plot(X_interpolated, Y2_interpolated, 'LineWidth', 0.5, 'LineStyle', '--', 'Color', '#FE1A1A'); + + fill([X_interpolated fliplr(X_interpolated)], [Y1_interpolated fliplr(Y2_interpolated)], [0 71 138] ./ 255, 'EdgeColor', 'none', 'FaceAlpha', 0.2); + + hold off +end + \ No newline at end of file