Sub topic 6
Building a bar chart
This chapter assumes you can select a range, use the Insert tab, and read a chart's series and categories as covered earlier in this tutorial. It uses the same Region and Sales range as the column chart chapter, so you can compare the two results directly.
What a bar chart is
A bar chart is a column chart rotated 90 degrees. Categories run down the vertical axis, and values run along the horizontal axis. Each bar's length encodes its value, and every bar starts at zero. Excel stores a bar chart the same way it stores a column chart, with one series and one set of categories. Only the orientation and a few default behaviors differ.
Use a bar chart instead of a column chart in these cases:
- Category labels are long. Horizontal text on a vertical axis stays readable. On a column chart's horizontal axis, long labels get rotated or truncated.
- There are many categories. A tall chart scrolls and scales better than a wide one.
- You want a ranking. Readers scan down a sorted list of bars more easily than across it.
- The categories are not a time sequence. Time usually reads left to right, so use a column or line chart for it.
Prepare the data
Use the layout from the data layout chapter: a header row, one category column, and one value column.
| Region | Sales |
|---|---|
| North | 120 |
| South | 95 |
| East | 140 |
| West | 80 |
Bar charts are most useful when the bars are sorted. Sort the source range before you chart it, because the chart follows the sheet order. Select a cell in the Sales column and choose Data > Sort Largest to Smallest. The range becomes East 140, North 120, South 95, West 80.
Insert the chart
- Select the range
A1:B5, including the header row. - Go to Insert > Charts > Insert Column or Bar Chart.
- Under 2-D Bar, choose Clustered Bar.
Excel places the chart on the sheet with the series name "Sales" as the title, and it shows a legend. With a single series, the legend adds nothing, so select it and press Delete.
The order problem
The first bar appears at the bottom of the chart, not the top. Excel draws the first category where the vertical axis starts, and that is the bottom, as on a graph. Your sorted list therefore appears upside down: West at the top and East at the bottom.
To reverse it:
- Double-click the vertical axis (the region names) to open the Format Axis pane.
- Under Axis Options, check Categories in reverse order.
The bars now read top to bottom in sheet order. This causes a side effect, shown in the diagram below. The horizontal value axis jumps to the top of the chart, because it crosses the category axis at the first category, which is now at the top.
To move the value axis back, stay in the same Format Axis pane. Under Horizontal axis crosses, choose At maximum category. The axis returns to the bottom, and the order stays correct.
Adjust bar width and spacing
Select any bar, then open Format Data Series. Two settings control the look:
- Gap Width is the space between bars as a percentage of bar thickness. The default is 219%, which makes thin bars. Values between 40% and 80% make bars that are easier to compare.
- Series Overlap matters only with more than one series. At 0% the bars in a group touch. Positive values overlap them, and negative values separate them.
Add data labels and simplify
Bars are easy to compare by eye, but exact numbers help. Select the chart, then choose Chart Elements (the plus icon) > Data Labels > Outside End. Labels at the end of each bar read cleanly because the bars have a common baseline.
Once the bars are labeled, the value axis and gridlines repeat the same information. You can delete the horizontal axis and the gridlines to reduce clutter. Keep the axis if readers need to estimate values for bars without labels, or if you plan to compare this chart with another that shares its scale.
Multiple series: clustered, stacked, and 100% stacked
If you add a second value column, such as Sales for a second year, the same chart type shows more detail. Choose the variant by the question:
| Variant | Each bar shows | Best for |
|---|---|---|
| Clustered bar | One bar per series in each category | Comparing series within a category |
| Stacked bar | Series segments added to a total length | Comparing totals, with a rough view of parts |
| 100% stacked bar | Each category scaled to 100% | Comparing proportions across categories |
In a stacked bar, only the first segment shares a baseline with the others, so comparing the lengths of later segments is hard. If the segment comparison matters more than the total, use a clustered bar.
You can change the variant without rebuilding the chart. Select the chart, then choose Chart Design > Change Chart Type and pick the variant.
Common errors
- Numbers stored as text. If a Sales value is left-aligned or shows a green triangle, Excel may treat it as text and plot a bar of length zero or skip the series. Convert the cells to numbers first.
- Including a totals row. If your range contains a Total row, the total becomes a bar that dwarfs the rest. Select only the category rows.
- Truncated axis. Setting the minimum of the value axis above zero makes bar lengths misleading, because length is the encoding. Leave the minimum at 0.
- Header cell not selected. If the top-left cell of the selection is a number, Excel may read the first row as data. Keep a text header in each column.
- Wrong chart category. Choosing a 3-D bar chart distorts length and makes the values harder to read. Prefer the 2-D variants.
Create the same chart with VBA
The macro below builds the sorted, labeled bar chart from A1:B5. It differs from the column chart macro in the chart type, and it adds the axis settings from the order problem section.
Sub CreateBarChart()
Dim co As ChartObject
Set co = ActiveSheet.ChartObjects.Add(Left:=100, Top:=50, Width:=400, Height:=250)
With co.Chart
.SetSourceData Source:=ActiveSheet.Range("A1:B5")
.ChartType = xlBarClustered
.HasTitle = True
.ChartTitle.Text = "Sales by Region"
.HasLegend = False
.Axes(xlCategory).ReversePlotOrder = True
.Axes(xlCategory).Crosses = xlMaximum
.SeriesCollection(1).HasDataLabels = True
.ChartGroups(1).GapWidth = 60
End With
End SubThe ReversePlotOrder line matches the Categories in reverse order checkbox. The Crosses = xlMaximum line matches At maximum category. Both are set on the category axis, even though the second one moves the value axis.
Checklist
- Sort the data in the order you want readers to see.
- Select the range with its header row and insert a Clustered Bar.
- Delete the legend if there is only one series.
- Reverse the category order and set the value axis to cross at the maximum category.
- Reduce the gap width and add outside-end data labels.
- Keep the value axis starting at zero.
Exercise
A bar chart of five departments shows the departments in the opposite order from your worksheet, and the value axis appears at the top after you fix the order. Which two settings in the category axis options produce the correct result, and why does the second one need to change?
Show answer
Check Categories in reverse order, so the first row of the sheet is drawn at the top. Then set Horizontal axis crosses to At maximum category. The value axis crosses the category axis at the first category, and reversing the order moves that first category to the top, so the value axis moves with it. Crossing at the maximum category puts the axis back at the bottom.
Exercise
You chart two years of sales for 12 products in a stacked bar chart, but readers cannot tell which year was higher for each product. What should you change, and why?
Show answer
Change the chart type to Clustered Bar. In a stacked bar, the second year's segment starts where the first ends, so the two segments do not share a baseline and are hard to compare. In a clustered bar, both years' bars start at zero within each product, so their lengths compare directly.