HomeGoogle DocsSpreadsheetEnabling the Horizontal Axis (Vertical) Gridlines in Charts in Google Sheets

Enabling the Horizontal Axis (Vertical) Gridlines in Charts in Google Sheets

Published on

Let me address a common problem that many of you may face while trying to enable the horizontal axis gridlines, i.e. vertical gridlines, in charts in Google Sheets.

The issue is that you may not see the option inside the chart editor panel to add/enable the horizontal axis gridlines.

Even if some of you could enable it, it may cause irregular data labels on the X-axis. In this post, I’m trying to address these two problems.

Google Sheets chart editor panel has an option to enable or disable, I mean to adjust the horizontal as well as vertical axis gridlines.

If your chart misses the vertical gridlines, that means, you must set the major gridline count that under Chart Editor > Customize > Gridlines > Horizontal Axis from “None” to “Auto” or any numbers from 0 to 10.

Sometimes you may not see the option “Horizontal Axis” to adjust values as above. I’ll tell you the reason why it’s not available so that you can sort out the issue.

Why Horizontal Axis Gridlines are Missing in My Line, Column, or Scatter Chart in Google Sheets?

There are mainly three reasons. Here are the three most prominent reasons. I’ve tested this only with Column, Line, and Scatter charts.

  1. The X-axis (the concerned column in your data) contains text strings, not numerical values (Number, Date, DateTime, or Time). If you have numerical values, then check it’s not formatted as “Plain Text” in the menu Format > Number.
  2. An option to change numeric X-axis values to text (labels) automatically got enabled in the chart editor panel.
  3. You have enabled the “Aggregation” option in the chart editor panel.

To get horizontal axis gridlines or you can say to add/enable vertical gridlines to a chart in Google Sheets, the X-axis values must be numbers, dates, timestamps, or time values.

If your data satisfies this, then you have no problem to get the option. Here is one example.

Sample Data # 1 (A1:C13):

MonthScheduledAchieved
Jan1.51
Feb11
Mar2.52
Apr63
May89
Jun88
Jul97.5
Aug77.5
Sept66
Oct46
Nov34
Dec23

If you plot a chart using this data you won’t be able to enable the horizontal axis gridlines in your chart editor panel as the X-axis values (column A) are text strings.

So in column A in your sheet, enter the month as Jan-20 in cell A2, Feb-20 in cell A3… which will be treated/converted as dates.

If not, enter 01/01/2020 in cell A2, 01/02/2020 in cell A3… (mine is DD/MM/YYYY format), and format that dates to month from the menu Format > Number > More formats > Custom Number Format.

Type mmm in the filed there.

Plot a Line Chart and Display Vertical and Horizontal Gridlines

I hope you have entered the data in A1:A13 as per the instructions above. If so, please follow the below steps to plot the line chart.

  1. Click Insert > Chart.
  2. The Setups Under the Chart Editor > Setup:
    • Chart Type: Line Chart.
    • Aggregate: Disable.
    • Switch Rows/Columns: Disable.
    • Use Row 1 as Headers: Enable.
    • Use Column A as Labels: Enable.
  3. The Setup Under the Customize Tab:
    • Vertical Axis > Treat Labels as Text: Disable.

If you follow the above settings, then you would get both vertical and horizontal axis gridlines on your line chart as shown below.

Horizontal axis gridlines in Google Sheets - Missing Labels

If you check the data labels on the X-axis, you can see that it doesn’t contain all the labels (months). How to solve it?

How to Get All the Data Labels on the X-Axis

I normally disable vertical gridlines (horizontal axis gridlines) by enabling the “Treat Labels as Text” option (please see point # 3 above).

This will help me to get all the data labels on the X-axis but in the cost of the horizontal axis gridlines.

I want to keep the horizontal axis gridlines and also show all the data labels. How to do that?

Click “Customize” in the chart editor and click Gridlines > Horizontal Axis.

Chart customization to change gridline count in Sheets

Then change “Major Gridline Count” from “Auto” to 10. This way you can show all the labels on the X-axis on a Google Sheets chart.

Vertical gridlines in Google Sheets - Complete Labels on X-axis

You have learned how to enable vertical gridlines in a line chart in Google Sheets. Now let’s see what to do when you want to aggregate the data for the chart.

Query or Pivot Table Instead of Chart Aggregation (Workaround)

As I have mentioned at the beginning of this post, you can’t enable horizontal axis gridlines, if you have selected the “Aggregate” in the “Setup” tab of the chart editor.

In case you want to aggregate the data and also want the vertical gridlines enabled, either use the Data menu Pivot Table to aggregate the data or use a Query formula. Then use that new range/summary for creating the chart.

Here is that example.

Sample Data # 2 (A1:C13):

DateZone 1Zone 2
20/06/202010080
21/06/20209080
21/06/20207064
21/06/20207080
22/06/20208880
22/06/20209096
22/06/20208080
23/06/20203032
23/06/2020100
23/06/2020100
23/06/20208080
23/06/2020150160

The above data is in “Sheet1”. Use the below formula in cell A1 in “Sheet2”.

=query(
     Sheet1!A:C,
     "Select A, sum(B),sum(C)
     where A is not null
     group by A
     label A 'Date', sum(B) 'Zone 1', sum(C) 'Zone 2'"
     ,0
)

Alternatively you can use the Pivot Table to aggregate the data as per the below settings.

  1. Select A1:C.
  2. Click Data > Pivot Table.
  3. Enable “New Sheet” and click “Create”.
  4. Then please follow the pivot table settings as per the image below.
Pivot table setting - aggregated data for chart

In the pivot editor, under “Filters” click the drop-down and unselect “(Blanks)”.

The chart based on this output will have the horizontal axis gridlines unless the “Treat Labels as Text” is enabled in the chart editor.

That’s all. Enjoy!

Prashanth KV
Prashanth KV
Your Trusted Google Sheets and Excel Guide Prashanth KV brings a wealth of experience in Google Sheets and Excel, cultivated through years of work with multinational corporations in Mumbai and Dubai. As a recognized Google Product Expert in Docs Editors, Prashanth shares his expertise through insightful blogging since 2012. Explore his blog for practical tips and guidance on maximizing your spreadsheet skills.

Creating Sequential Dates in Equally Merged Cells in Google Sheets

Do you know how to create sequential dates in equally merged cells across a...

Running Total By Month in Excel

This tutorial demonstrates how to calculate the running total by month in a range...

SORT and SORTBY – Excel Vs Google Sheets

While Excel offers the SORT and SORTBY functions for sorting a table, Google Sheets...

Get Top N Values Using Excel’s FILTER Function

When using the FILTER function in Excel to extract the top N values, it's...

More like this

Creating Sequential Dates in Equally Merged Cells in Google Sheets

Do you know how to create sequential dates in equally merged cells across a...

Interactive Random Task Assigner in Google Sheets

You have multiple tasks and multiple people. Here's a fun way to randomly assign...

Google Sheets Bar and Column Chart with Target Coloring

To color each data point in the column or bar chart according to the...

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.