How does one use bar() to show multiple bars for a single X-axis value?
Afficher commentaires plus anciens
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.
Réponses (1)
Oleg Komarov
le 27 Juil 2011
bar([10 20; NaN NaN])
set(gca,'xlim',[0 2],'xtick',1)
Catégories
En savoir plus sur Bar Plots dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!