Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to plot hist with log scale

Tags:

matlab

x = [1: 1000]
hist(x)

then, there are figure showing the histogram, but if i set the axes property and Y-axis to log. I cannot see anything in the figure. How to plot the histogram with log scale.

like image 870
Ben Avatar asked Jul 25 '11 07:07

Ben


3 Answers

Try set(gca, 'Xscale', 'log') for plotting log on X axis. It worked for me I am using 7.12.0 or 2011a. Check the axis reference for more help.

like image 150
cwadding Avatar answered Oct 24 '22 08:10

cwadding


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)
like image 32
Guillaume Thomas Avatar answered Oct 24 '22 07:10

Guillaume Thomas


As far as I know, it's not available as a native matlab function:

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

But this article also explains several workarrounds.

like image 3
Kjellski Avatar answered Oct 24 '22 08:10

Kjellski