How does one use bar() to show multiple bars for a single X-axis value?
Mostrar comentarios más antiguos
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.
Respuestas (1)
Oleg Komarov
el 27 de Jul. de 2011
bar([10 20; NaN NaN])
set(gca,'xlim',[0 2],'xtick',1)
Categorías
Más información sobre Bar Plots en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!