Histogram with yaxis in percent and xaxis normal increments Matlab

352 Views Asked by At

x = rand(1000,1);

bar(hist(x)*100/length(x)); axis( 10, 2, 100)

Problem I have is that the x axis is represented from 1 to 10, i need them to be grouped fro the lowest number in the array to the highest. So if the lowest was 200 and the highest 900 then i need the x to be from 200 to 900 incrementing by 70. If i change the axis the bar width and position stays the same. Don't have the code with me since I left it at work.

1

There are 1 best solutions below

0
On

You may set x-labels on a bar plot using bar with two input arguments:

c=hist(x)*100/length(x)
%start
s=200;
%span (900-s)
m=700;
bar([s:m/(numel(c)-1):s+m],c)

I did not use your step size, because it did not fit.