Since the two calls to bar in plotyy are independent of each other, there's no way for the information that you want two independent bar plots to look like together they're grouped. Fortunately, there's a relatively simple way to fake it -- will just use a trivial example rather than try to explain; the "trick" should be self-evident.
N=5;
y1=rand(N,2); y2=100*rand(N,2);
y1(:,2)=nan;y2(:,1)=nan;
x=[1:N].';
hAx=plotyy(x,y1,x,y2,@bar,@bar);
set(hAx(2),'xtick',[])
set(hAx(1),'xticklabel',[200:100:500 700])
Well, I'll try to add some explanatory words too, despite the promise... :)
The "trick" is to make the data arrays the number of columns wide that you need grouped bars (here, two, one for each y-axis); it's over columns that Matlab 'group' works. All the HG plot routines have the feature that NaN is handled gracefully simply by not being plotted but the place holder is still there. Hence, as above, there are two bars for each plot but by swapping which column is NaN, one is drawn left, the other right of center and voila! you've got the appearance of 'group' with disparate bar graphs...
Salt to suit with your own data, of course.
Best Answer