2011-07-25 22 views
7
x = [1: 1000] 
hist(x) 

然後,有圖顯示的直方圖,但如果我設置軸屬性和Y軸記錄。我在圖中看不到任何東西。如何繪製對數刻度的直方圖。如何繪製日誌規模的組織

回答

3

我會建議使用histc與日誌的邊緣和barplot

help histc 
-- Function File: N = histc (Y, EDGES) 

matlab> edges=log(1:100:1000); 
matlab> h=histc(x,edges) 
matlab> bar(1:100:1000, h) 
+0

您必須添加 'histc' 選項與巴,以保持histc邊緣功能:巴(1:100:1000,H, 'histc') – Eudhan

6

嘗試使用set(gca, 'Xscale', 'log')來繪製X軸上的日誌。它爲我工作我使用7.12.0或2011a。檢查axis reference尋求更多幫助。

0

嘗試:

function semilogxhist(val,M) 
% semilogxhist - generate histogram with M bars and log-scale x axis 
if nargin<2; M=min(30,sqrt(length(val))); end 
vmin=min(val); vmax=max(val); 
edges=vmin*(vmax/vmin).^([0:M]/M); 
count=histc(val,edges); 
if size(count,2)==1, count=count'; end 
x=edges(sort([1:M 1:M])); 
y=[0 count(sort([1:M-1 1:M-1])) 0]; 
% outline only: semilogx(x, y, '-'); 
plot(x, y, '-'); fill(x, y, 'b'); set(gca,'XScale','log');