Hello mad labbers
I'm having trouble creating a grouped bar chart using figure handles.
It ends up being stacked instead of grouped when adding data to it using its handle. The two cases below illustrates the problem – A gives the intended plot, but the plot in B is stacked instead of grouped.
Does anyone if one can get plot A using a handle as in B?
x = [1 2 3]; y1 = [3 6 8]; y2 = [6 5 3];
Case A:
y = [y1; y2]'; ax = subplot(1, 2, 1); hold(ax, 'on'); bar(ax, x, y, 'grouped') xlabel('A')
Case B:
ax = subplot(1, 2, 2); hold(ax, 'on') bar(ax, x, y1, 'grouped'); bar(ax, x, y2, 'grouped'); xlabel('B')
Best Answer