Instead of a legend, you can solve this problem using label labels, for example:
set(gca,'xticklabel', l)

This will mean every bar. If you want to use legend , you need to have matrix data, so several columns per record will be displayed on the panel chart. for instance
Y=rand(10,6) h = bar(Y); colormap(summer(n)); grid on l = cell(1,6); l{1}='L'; l{2}='B'; l{3}='R'; l{4}='P'; l{5}='h'; l{6}='Ri'; legend(h,l);

Or you can use different calls to bar() as follows:
h = bar(diag(Y));
But then you get an offset for each bar:

Thus, the only way to do this with legend is to build each bar separately, similar to what was discussed here .
source share