Chart - Tick Labels

The vertical and horizontal divisions of a chart axis may be labeled with tick labels, text that describes the division, most commonly its category name or value. A tick labels object is not a collection. There is no object that represents in individual tick label.

Tick label text for a category axis comes from the name of each category. The default tick label text for a category axis is the number that indicates the position of the category relative to the low end of this axis. To change the number of unlabeled tick marks between tick-mark labels, you must change the TickLabelSpacing property for the category axis.

Tick label text for the value axis is calculated based on the major_unit, minimum_scale, and maximum_scale properties of the value axis. To change the tick label text for the value axis, you must change the values of these properties.

Candidate protocol

>>> tick_labels = value_axis.tick_labels

>>> tick_labels.font
<pptx.text.Font object at 0xdeadbeef1>

>>> tick_labels.number_format
'General'
>>> tick_labels.number_format = '0"%"'
>>> tick_labels.number_format
'0"%"'

>>> tick_labels.number_format_is_linked
True
>>> tick_labels.number_format_is_linked = False
>>> tick_labels.number_format_is_linked
False

# offset property is only available on category axis
>>> tick_labels = category_axis.tick_labels
>>> tick_labels.offset
100
>>> tick_labels.offset = 250
>>> tick_labels.offset
250

Feature Summary

  • TickLabels.font – Read/only Font object for tick labels.
  • TickLabels.number_format – Read/write string.
  • TickLabels.number_format_is_linked – Read/write boolean.
  • TickLabels.offset – Read/write int between 0 and 1000, inclusive.

Microsoft API

Font
Returns the font of the specified object. Read-only ChartFont.
NumberFormat
Returns or sets the format code for the object. Read/write String.
NumberFormatLinked
True if the number format is linked to the cells (so that the number format changes in the labels when it changes in the cells). Read/write Boolean.
Offset
Returns or sets the distance between the levels of labels, and the distance between the first level and the axis line. Read/write Long.

XML specimens

Example category axis XML showing tick label-related elements:

<c:catAx>
  <c:axId val="-2097691448"/>
  <c:scaling>
    <c:orientation val="minMax"/>
  </c:scaling>
  <c:axPos val="b"/>
  <c:numFmt formatCode="General" sourceLinked="0"/>
  <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:lblAlgn val="ctr"/>
  <c:lblOffset val="100"/>
  <c:noMultiLvlLbl val="0"/>
</c:catAx>