bar graph grouped with custom x-axis

3 vues (au cours des 30 derniers jours)
Nick
Nick le 2 Déc 2013
Commenté : Nick le 9 Déc 2013
I need a bar graph containing 3 sets of Y values and I'd like to apply the 'grouped' style. (i.e. y1 = round(rand(1,49)*10); y2 = round(rand(1,49)*10); y3 = round(rand(1,49)*10);) (See http://www.mathworks.de/de/help/matlab/ref/bar.html, "Bar Graph Styles".)
On top of that, I have a custom x-axis. (i.e. x = -24:1:24) (See http://www.mathworks.de/de/help/matlab/ref/bar.html, "X-Axis Tick Labels".)
Can I combine these two functions in one bar graph?

Réponse acceptée

dpb
dpb le 2 Déc 2013
Sure, just set the 'xticklabel' property as desired. You may also want to set 'xtick' to an appropriate number of values. Just remember the tick values must be in range of the axes limits to display; the tick labels can then be anything on a 1:1 correspondence to the tick marks.
There are examples in the 2D graphics for customizing graphics...
  1 commentaire
Nick
Nick le 9 Déc 2013
Thanks for your answer! I finally got round to trying this again...
Basically I just had to define for the x axis an array (1,n), and for the y axis an array (n,m).
As for my example: Grid = xGridOut; % 1x202 double Freq = [xFreqOut; xFreqIn1; xFreqIn2]'; % 202x3 double bar(Grid, Freq, 'grouped')
My next challenge will be a 3d bar graph.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Discrete Data Plots dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by