ChartAxis

class ChartAxis

A primary chart axis, accessed through Chart.category_axis or Chart.value_axis.

Use set() to change several attributes in one operation. On xlwings Lite, use the asynchronous getters to fetch the current values from Excel.

>>> chart = xw.books["Book1"].sheets[0].charts[0]
>>> chart.value_axis.set(
...     title="Revenue", minimum_scale=0, major_unit=10_000
... )

Added in version 0.37.5.

property api: Any

Returns the native pywin32 object on Windows.

async get_major_unit()

Fetches the resolved major-unit interval.

Requires xlwings Lite.

Return type:

float

async get_maximum_scale()

Fetches the resolved maximum scale.

Requires xlwings Lite.

Return type:

float

async get_minimum_scale()

Fetches the resolved minimum scale.

Requires xlwings Lite.

Return type:

float

async get_number_format()

Fetches the tick-label number format.

Requires xlwings Lite.

Return type:

str

async get_title()

Fetches the axis title. Returns None if the axis or title is hidden.

Requires xlwings Lite.

Return type:

str | None

async get_visible()

Fetches whether the axis is shown.

Requires xlwings Lite.

Return type:

bool

property major_unit: float

Returns or sets the interval between major tick marks. Set to None to restore Excel’s automatic interval; reads return the resolved value.

Setter type:

float | None

property maximum_scale: float

Returns or sets the maximum scale. Set to None to restore Excel’s automatic scale; reads return the resolved numeric value.

Setter type:

float | None

property minimum_scale: float

Returns or sets the minimum scale. Set to None to restore Excel’s automatic scale; reads return the resolved numeric value.

Setter type:

float | None

property number_format: str

Returns or sets the format code for the axis tick labels.

set(*, title=..., minimum_scale=..., maximum_scale=..., major_unit=..., number_format=..., visible=...)

Sets one or more axis attributes in one operation.

Only supplied attributes are changed, and all arguments are validated before anything is written. visible=True is applied before the other attributes; visible=False is applied last so it describes the final state.

Parameters:
  • title (str | None) – Axis title, or None to hide it.

  • minimum_scale (float | None) – Minimum scale, or None for automatic scaling.

  • maximum_scale (float | None) – Maximum scale, or None for automatic scaling.

  • major_unit (float | None) – Positive major-unit interval, or None for automatic.

  • number_format (str) – Format code for the tick labels.

  • visible (bool) – Whether the axis is shown.

property title: str | None

Returns or sets the axis title. Setting it to None hides the title; setting it to a string shows the axis and its title.

property visible: bool

Returns or sets whether the axis is shown.