56 lines
1.3 KiB
Matlab
56 lines
1.3 KiB
Matlab
close all
|
|
% histogram
|
|
figure()
|
|
x = randn(2000,1);
|
|
hist(x, 50);
|
|
h = findobj(gca, 'Type','patch');
|
|
set(h(1), 'FaceColor',[.2,.2,.2], 'EdgeColor','w', 'linewidth',2)
|
|
grid('off')
|
|
h = gridxy([],get(gca,'ytick'),'color','w','linewidth',2)
|
|
box('off');
|
|
uistack(h, 'top')
|
|
xlabel('Data')
|
|
ylabel('Count')
|
|
set(gcf, 'PaperUnits', 'centimeters');
|
|
set(gcf, 'PaperSize', [11.7 9.0]);
|
|
set(gcf, 'PaperPosition',[0.0 0.0 11.7 9.0]);
|
|
|
|
% bar plot
|
|
figure
|
|
x = rand(10,1);
|
|
gray = [.5,.5,.5];
|
|
|
|
bar(1, mean(x), 'EdgeColor','w','FaceColor', gray);
|
|
hold on
|
|
|
|
bar(2, mean(x), 'EdgeColor','w','FaceColor', gray);
|
|
plot(0*x + 2, x, 'ok');
|
|
|
|
bar(3, mean(x), 'EdgeColor','w','FaceColor', gray);
|
|
errorbar(3, mean(x), std(x), 'ok');
|
|
|
|
bar(4, mean(x), 'EdgeColor','w','FaceColor', gray);
|
|
errorbar(4, mean(x), std(x)/sqrt(length(x)), 'ok');
|
|
set(gca, 'xtick',[])
|
|
ylabel('uniformly distributed random data in [0,1]')
|
|
box('off')
|
|
title('different forms of bar plots')
|
|
set(gcf, 'PaperUnits', 'centimeters');
|
|
set(gcf, 'PaperSize', [11.7 9.0]);
|
|
set(gcf, 'PaperPosition',[0.0 0.0 11.7 9.0]);
|
|
hold off
|
|
|
|
% box plot
|
|
figure
|
|
x = rand(10,1);
|
|
x(10) = 3;
|
|
boxplot(x)
|
|
set(gca, 'xtick',[])
|
|
ylabel('data')
|
|
box('off')
|
|
title('box plot')
|
|
set(gcf, 'PaperUnits', 'centimeters');
|
|
set(gcf, 'PaperSize', [11.7 9.0]);
|
|
set(gcf, 'PaperPosition',[0.0 0.0 11.7 9.0]);
|
|
hold off
|