For axis axis labels, it is true that they should be placed after the BAR is called. This will take care of a single axis problem. However, you will probably notice that your Y axis labels, in particular, can be written on top of each other if they are too long. You have several options to fix this. First, you can adjust the font size in your call to YLABEL :
ylabel('Number of Occurrences','FontSize',7);
Secondly, you can convert one long label to a multi-line label using an array of row cells instead of a single row
ylabel({'Number of' 'Occurrences'});
To add a caption to the whole picture, the best option is perhaps to create a static UICONTROL text object and adjust its position, so it is located next to the top of the figure. First, you can get the size and position of the shape to help place the text box on the top and center:
figureSize = get(gcf,'Position'); uicontrol('Style','text',... 'String','My title',... 'Position',[(figureSize(3)-100)/2 figureSize(4)-25 100 25],... 'BackgroundColor',get(gcf,'Color'));
This will create a static text box with a width of 100 pixels and a height of 25 pixels, located in the center of the upper part of the picture and with the same background color as the figure.
gnovice
source share