MATLAB Answers


How can I display a bar chart ?

Asked by Mallouli Marwa on 18 Jun 2019
Latest activity Commented on by Mallouli Marwa on 20 Jun 2019
How can I display a bar chart like the attached one ?
Best regards.


Sign in to comment.

2 Answers

Answer by Aravind Ravikumar on 19 Jun 2019
 Accepted Answer

What you are looking for is 2-D Bar Graph. You can add legends using legend.


How can I add x values (20Hz, 30Hz, 40Hz) like in the attached figure
x = [3 4;1.5 1.75;0.25 0.3];
This code will produce bar graph like the attached image. gca will select the current axes and then you could specify the xticklabel for the bar graph.

Sign in to comment.

Answer by the cyclist
on 18 Jun 2019

Use the bar function.


How can I add a legend in the corner of the curve like in the attached curve ?
the cyclist
on 19 Jun 2019
I suggest you take a look at the MATLAB Plot Gallery, which has examples of lots of plot types, along with the code that produces them. This may save you time asking about everything small addition that you want, one at a time.

Sign in to comment.