% generate data: x = randn(1, 100000); % histogram: [h,b] = hist(x, 100); % normalize: bs = b(2)-b(1); h = h/sum(h)/bs; % plot: bar(b, h); xlabel('x'); % median, quartile: q = quartiles(x); %q = quantile(x, [0.25, 0.5, 0.75 ]); % plot: hold on; bar(b(b=q(1)) & (b=q(1)) & (b=q(2)) & (b=q(2)) & (b=q(3)), h(b>=q(3)), 'FaceColor', [0.5 0 0.5]); hold off;