Question #506

# In Matlab, how to draw a bar graph?

Merged questions

The MATLAB ﻿`bar()` function creates a bar graph in a figure. Let's consider the following vectors :

``````x = [1970 1980 1990 2000 2010 2020];
y = [185  248  125  53   200  189];``````

The following creates a bar graph with one bar for each element of ﻿`y`:

``﻿bar (y)`` The following draws the bars at the location specified by ﻿`x`:

``bar(x,y);`` 4 events in history
Question by Alphonsio 12/22/2020 at 06:08:27 PM
How to draw a bar graph in MATLAB?
Answer by Alphonsio 12/22/2020 at 06:07:54 PM

The MATLAB ﻿`bar()` function creates a bar graph in a figure. Let's consider the following vectors :

``````x = [1970 1980 1990 2000 2010 2020];
y = [185  248  125  53   200  189];``````

The following creates a bar graph with one bar for each element of ﻿`y`:

``﻿bar (y)`` The following draws the bars at the location specified by ﻿`x`:

``bar(x,y);`` Answer by Alphonsio 12/22/2020 at 06:04:52 PM

The MATLAB ﻿`bar()` function creates a bar graph in a figure. Let's consider the following vectors :

``````x = [1970 1980 1990 2000 2010 2020];
y = [185  248  125  53   200  189];``````

The following display the vectors in bar graphs :

``﻿bar (y)`` ``bar(x,y);`` Question by Alphonsio 12/22/2020 at 05:52:22 PM
In Matlab, how to draw a bar graph?

Icons proudly provided by Friconix.