How to build a chart with a magazine scale

x = [1: 1000] hist(x) 

then there is a chart showing a histogram, but if I set the axis property and the Y axis to enter the log. I don’t see anything in the picture. How to build a bar chart with a log scale.

+7
source share
4 answers

Try set(gca, 'Xscale', 'log') to build the log along the X axis. This worked for me, I use 7.12.0 or 2011a. For more details see the link to the axis .

+6
source

I would suggest using histc with log edges and 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) 
+3
source

As far as I know, it is not available as a matlab built-in function:

http://www.mathworks.com/support/solutions/en/data/1-2ZUTKK/?solution=1-2ZUTKK

But this article also explains several work options.

+3
source

Try:

 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'); 
0
source

All Articles