y轴应为频率(直方图部分),而x轴为用于绘制直方图的xdata。基本上我需要的是一个直方图,但不是酒吧,应该有点。
答案 0 :(得分:1)
我使用histcounts
命令执行此操作。它类似于histogram
命令,但它不是绘制数据,而是返回每个bin中的数字和bin边缘。然后,您可以使用常规plot
命令将其绘制为点。
x = randn(1,1000); %Generate some data to plot
figure(1); clf;
subplot(2,1,1); hold on;
h = histogram(x,'normalization','probability');
title('Plotted as a histogram');
ylabel('Frequency');
subplot(2,1,2); hold on;
[N, edges] = histcounts(x,'normalization','probability');
centers = (edges(1:end-1) + edges(2:end))./2; %histcounts gives the bin edges, but we want to plot the bin centers
plot(centers,N,'ko');
title('Plotted as points');
ylabel('Frequency');