开发者

Matlab question: fixing the scale of Y axis in hist

开发者 https://www.devze.com 2023-03-20 06:22 出处:网络
I want to draw several histograms. But I want the Y a开发者_运维知识库xis to be fixed, like from 1000 to 1 by 100. How can I specify them。

I want to draw several histograms. But I want the Y a开发者_运维知识库xis to be fixed, like from 1000 to 1 by 100. How can I specify them。

Please advise.


Consider this example:

%# some data
X = randn(1000,3);
nbins = 10;

%# compute frequencies and bins
%#[count,bins] = hist(X, nbins);
count = zeros(10,size(X,2));
bins = zeros(10,size(X,2));
for i=1:size(X,2)
    [count(:,i),bins(:,i)] = hist(X(:,i),nbins);
end

%# show histograms
for i=1:size(X,2)
    subplot(1,size(X,2),i)
    bar(bins(:,i), count(:,i),'hist')
    set(gca, 'YTick',0:100:4000, 'YLim',[0 400])
end

Matlab question: fixing the scale of Y axis in hist


The axis command is what you're looking for. You specify the [XMIN XMAX YMIN YMAX]. This example will have all histograms capped at a value of 5. Also, you're asking a bunch of questions about MATLAB today without seemingly doing any research. Please ask a search engine and show that you've at least tried something.

clf;
subplot(1,2,1); hist(rand(1,10)); axis([0 1 0 5]);
subplot(1,2,2); hist(rand(1,10)); axis([0 1 0 5]);
0

精彩评论

暂无评论...
验证码 换一张
取 消