Clear Filters
Clear Filters

bar graph grouped with custom x-axis

4 views (last 30 days)
Nick
Nick on 2 Dec 2013
Commented: Nick on 9 Dec 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?

Accepted Answer

dpb
dpb on 2 Dec 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 Comment
Nick
Nick on 9 Dec 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.

Sign in to comment.

More Answers (0)

Categories

Find more on Discrete Data Plots in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!