I have this histogram in MATLAB created using the command bar:
bar
I was wondering if there is a way to get rid of empty spaces between 2478 and 2886 and between 4314 and 5130
If I can make the bars have an equal amount of space between them, that would be ideal.
As described in the documentation bar,
bar(x,y)draws stripes at the locations indicated x.
bar(x,y)
x
which means this behavior is intended: each line is drawn in the exact position indicated x.
, categorical, x , . , MATLAB, x , x(i) x - i - , .
categorical
x(i)
i
bar(categorical(x), y)
x .
[1, 2, 3, ..., 13]
:
x = [1886,2070,2274,2478,2886,3090,3294,3498,3702,3960,4110,4314,5130]; y = rand(1,13)*5 + 32;
bar( 1:numel(y), y ); set( gca, 'XTickLabel', x );