How does one use bar() to show multiple bars for a single X-axis value?

bar( [1,2], [10,20;30,40] ); draws a bar graph with two X ticks, 1 and 2. At X=1 there are two bars of height 10 and 20, and at X=2 there are two bars of height 30 and 40.
But what if I want a bar graph with one Xtick showing two bar of height 10 and 20. bar( [1], [10,20] ) doesn't work: "X must be same length as Y"
Is there some trick to getting bar() to work in this case? My code has to work with a wide range of datasets, some of which have the one-xtick case.

Tags

Asked:

Jim
on 27 Jul 2011

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!