Reputation: 225
I want to draw several histograms. But I want the Y axis to be fixed, like from 1000 to 1 by 100. How can I specify them。
Please advise.
Upvotes: 2
Views: 9995
Reputation: 124563
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
Upvotes: 2
Reputation: 15996
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]);
Upvotes: 1