Chart - BaseAxis.has_gridlines

A chart axis can have gridlines that extend the axis tick marks across the body of the plot area. Gridlines for major and minor tick marks can be controlled separately. Both vertical and horizontal axes can have gridlines.

Candidate protocol

>>> value_axis = chart.value_axis
>>> value_axis.has_major_gridlines
False
>>> value_axis.has_major_gridlines = True
>>> value_axis.has_major_gridlines
True
>>> category_axis = chart.category_axis
>>> category_axis.has_minor_gridlines
False
>>> category_axis.has_minor_gridlines = True
>>> category_axis.has_minor_gridlines
True

Can be implemented in BaseAxis since the controlling element appears in EG_AxShared.

Microsoft API

Axis.HasMajorGridlines
True if the axis has major gridlines. Read/write Boolean.
Axis.HasMinorGridlines
True if the axis has minor gridlines. Read/write Boolean.
Axis.MajorGridlines
Returns the major gridlines for the specified axis. Read-only Gridlines.
Axis.MinorGridlines
Returns the minor gridlines for the specified axis. Read-only Gridlines.

Gridlines.Border

Gridlines.Format.Line

Gridlines.Format.Shadow

PowerPoint behavior

  • Turning gridlines on and off is controlled from the ribbon (on the Mac at least)
  • Each set of gridlines (horz/vert, major/minor) can be formatted individually.
  • The formatting dialog has panes for Line, Shadow, and Glow & Soft Edges

XML Semantics

  • Each axis can have a <c:majorGridlines> and a <c:minorGridlines> element.
  • The corresponding gridlines appear if the element is present and not if it doesn’t.
  • Line formatting, like width and color, is specified in the child <c:spPr> element.

XML specimens

Example axis XML for a single-series line plot:

<c:catAx>
  <c:axId val="-2097691448"/>
  <c:scaling>
    <c:orientation val="minMax"/>
  </c:scaling>
  <c:delete val="0"/>
  <c:axPos val="b"/>
  <c:majorGridlines/>
  <c:minorGridlines/>
  <c:numFmt formatCode="General" sourceLinked="0"/>
  <c:majorTickMark val="out"/>
  <c:minorTickMark val="none"/>
  <c:tickLblPos val="nextTo"/>
  <c:txPr>
    <a:bodyPr/>
    <a:lstStyle/>
    <a:p>
      <a:pPr>
        <a:defRPr sz="1000"/>
      </a:pPr>
      <a:endParaRPr lang="en-US"/>
    </a:p>
  </c:txPr>
  <c:crossAx val="-2097683336"/>
  <c:crosses val="autoZero"/>
  <c:auto val="1"/>
  <c:lblAlgn val="ctr"/>
  <c:lblOffset val="100"/>
  <c:noMultiLvlLbl val="0"/>
</c:catAx>