Adding breakpoints on the x-Axis of Histogram MATLAB

141 views Asked by At
OT = [124 124 124 125 125 125 126 249 249 250 250 250 312 312 312 438]
MYBINS = min (OT) : max(OT);
hist (OT,MYBINS);

I want to plot the histogram of OT and I set my bins from min(OT) to max (OT). since the element are far from each other my histogram bars are very small.

I was just wondering how I can modify the x-Axis so it would for example only show the values of the OT next to each other such as 124,125,126,249,250,312,438 and have the corresponding bars on top of them instead of spanning the entire x-Axis.

UPDATE: with the following code I can get the bars above the exact values with the value written underneath, I was just wondering how I can add breaks between far values on the x-Axis?

OTU = unique (OT);
OTUS = sort (OTU);
MYBINS = (OTUS);
hist (OT,MYBINS);

This is how it looks normally but I would like to have the bars next to each other with the corresponding values below them so the bars would be larger and easier to see

FEmpT.jpg

1

There are 1 answers

4
ioums On BEST ANSWER

If you just get the data from the hist function you can plot it in other, more flexible, ways. Is this more like what you want?

OT = [124 124 124 125 125 125 126 249 249 250 250 250 312 312 312 438]
binVals = unique(OT);
histVals = hist(OT, binVals);
bar(1:length(histVals), histVals);
set(gca,'XTickLabel', mat2cell(binVals));