diff --git a/plotting/code/errorbarplot.m b/plotting/code/errorbarplot.m new file mode 100644 index 0000000..6910d1e --- /dev/null +++ b/plotting/code/errorbarplot.m @@ -0,0 +1,43 @@ +% fake some data +x_data = 0:2*pi/10:2*pi; +sym_data = sin(repmat(x_data, 10,1)) * 0.75 + (randn(10, length(x_data)) .* cos(repmat(x_data, 10,1))); +asym_data = sin(repmat(x_data, 10,1)) * 0.75 + (randn(10, length(x_data)) .* cos(repmat(x_data, 10,1)) + 0.5); + +% get some data characteristics +avg_sym = mean(sym_data, 1); +err_sym = std(sym_data, [], 1); +avg_asym = median(asym_data, 1); +err_upper_asym = prctile(asym_data, 75, 1); +err_lower_asym = prctile(asym_data, 25, 1); + +fig = figure(); +set(fig, 'paperunits', 'centimeters', 'papersize', [15 6.5], ... + 'paperposition', [0.0 0.0 15, 6.5], 'color', 'white') +subplot(1,3,1) +errorbar(x_data, avg_sym, err_sym, 'marker', 'o') +xlim([-.5, 6.5]) +xlabel('x-data') +ylabel('y-data') +box('off') + +subplot(1,3,2) +errorbar(x_data, avg_asym, err_lower_asym, err_upper_asym, 'marker', 'o') +xlim([-.5, 6.5]) +yticklabels([]) +xlabel('x-data') +box('off') + +subplot(1,3,3) +hold on +p = fill(cat(2, x_data, fliplr(x_data)), ... + cat(2, avg_sym - err_sym, fliplr(avg_sym + err_sym)), ... + 'b'); +p.FaceAlpha = 0.125; +p.EdgeColor = 'w'; +xlim([-.5, 6.5]) +yticklabels([]) +box('off') +xlabel('x-data') +plot(x_data, avg_sym, 'b', 'linewidth', 1.) + +saveas(fig, '../lecture/images/errorbars', 'pdf') diff --git a/plotting/lecture/images/errorbars.pdf b/plotting/lecture/images/errorbars.pdf new file mode 100644 index 0000000..49ade7a Binary files /dev/null and b/plotting/lecture/images/errorbars.pdf differ