MATLAB Answers

# Plotting the Bar chart in Matlab

1 view (last 30 days)
Hi all,
I am plotting the bar chart in matlab with the following code,
x = [1 2 3];
figure,
bar(x,[3 2 1;6 5 4;9 8 7])
Here, I am getting the following chart when I run it, but it should be (3,6,9) should be below the 1(x-axis), (2,5,8) under the 2(x-axis), similarly (1,4,7) in 3(xaxis).
It would be great, if anyone could help. Thanks,
Satish J
##### 0 CommentsShowHide -1 older comments

Sign in to comment.

### Answers (1)

VBBV on 6 May 2021
%if true
x = [1 2 3];
figure,
bar(x,[3 6 9;2 5 8;1 4 7])
Do you mean this ?
##### 1 CommentShowHide None
Satish Jawalageri on 6 May 2021
Thanks for your reply.
Yes, it should be like that. But I am extracting the data from excel. So, just I will be having only rows.
And when I remove 9 8 7, It works well.
x = [1 2 3];
figure,
bar(x,[3 2 1;6 5 4;9 8 7])

Sign in to comment.

### Community Treasure Hunt

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

Start Hunting!