Axis class

Axis class

Encapsulates the object that represents an axis of chart.

The Axis type exposes the following members:

Properties

PropertyDescription
areaGets the Axis.area.
is_automatic_min_valueIndicates whether the min value is automatically assigned.
min_valueRepresents the minimum value on the value axis.
is_automatic_max_valueIndicates whether the max value is automatically assigned.
max_valueRepresents the maximum value on the value axis.
is_automatic_major_unitIndicates whether the major unit of the axis is automatically assigned.
major_unitRepresents the major units for the axis.
is_automatic_minor_unitIndicates whether the minor unit of the axis is automatically assigned.
minor_unitRepresents the minor units for the axis.
axis_lineGets the appearance of an Axis.
major_tick_markRepresents the type of major tick mark for the specified axis.
minor_tick_markRepresents the type of minor tick mark for the specified axis.
tick_label_positionRepresents the position of tick-mark labels on the specified axis.
cross_atRepresents the point on the value axis where the category axis crosses it.
cross_typeRepresents the Axis.cross_type on the specified axis where the other axis crosses.
log_baseRepresents the logarithmic base. Default value is 10.Only applies for Excel2007.
is_logarithmicRepresents if the value axis scale type is logarithmic or not.
is_plot_order_reversedRepresents if Microsoft Excel plots data points from last to first.
axis_between_categoriesRepresents if the value axis crosses the category axis between categories.
tick_labelsReturns a Axis.tick_labels object that represents the tick-mark labels for the specified axis.
tick_label_spacingRepresents the number of categories or series between tick-mark labels. Applies only to category and series axes.
is_auto_tick_label_spacingIndicates whether the spacing of tick label is automatic
tick_mark_spacingReturns or sets the number of categories or series between tick marks. Applies only to category and series axes.
display_unitRepresents the unit label for the specified axis.
cust_unitSpecifies a custom value for the display unit.
custom_unitSpecifies a custom value for the display unit.
display_unit_labelRepresents a unit label on an axis in the specified chart.
Unit labels are useful for charting large values— for example, in the millions or billions.
is_display_unit_label_shownRepresents if the display unit label is shown on the specified axis.
titleGets the axis’ title.
category_typeRepresents the category axis type.
base_unit_scaleRepresents the base unit scale for the category axis.
major_unit_scaleRepresents the major unit scale for the category axis.
minor_unit_scaleRepresents the major unit scale for the category axis.
is_visibleRepresents if the axis is visible.
major_grid_linesRepresents major gridlines on a chart axis.
minor_grid_linesRepresents minor gridlines on a chart axis.
has_multi_level_labelsIndicates whether the labels shall be shown as multi level.
axis_labelsGets the labels of the axis after call Chart.Calculate() method.
binsRepresents bins on a chart(Histogram/Pareto) axis

Methods

MethodDescription
get_axis_textsGets the labels of the axis after call Chart.Calculate() method.

Example

From the following codes , you can learn how to set unit, maximum and minimum value of Axis.

from aspose.cells import Workbook
from aspose.cells.charts import ChartType, CrossType

# Instantiating a Workbook object
workbook = Workbook()
# Adding a new worksheet to the Excel object
sheetIndex = workbook.worksheets.add()
# Obtaining the reference of the newly added worksheet by passing its sheet index
worksheet = workbook.worksheets[sheetIndex]
# Adding a sample value to "A1" cell
worksheet.cells.get("A1").put_value(50)
# Adding a sample value to "A2" cell
worksheet.cells.get("A2").put_value(100)
# Adding a sample value to "A3" cell
worksheet.cells.get("A3").put_value(150)
# Adding a sample value to "B1" cell
worksheet.cells.get("B1").put_value(4)
# Adding a sample value to "B2" cell
worksheet.cells.get("B2").put_value(20)
# Adding a sample value to "B3" cell
worksheet.cells.get("B3").put_value(50)
# Adding a chart to the worksheet
chartIndex = worksheet.charts.add(ChartType.COLUMN, 5, 0, 25, 5)
# Accessing the instance of the newly added chart
chart = worksheet.charts[chartIndex]
# Adding NSeries (chart data source) to the chart ranging from "A1" cell to "B3"
chart.n_series.add("A1:B3", True)
# Set the max value of value axis
chart.value_axis.max_value = 200
# Set the min value of value axis
chart.value_axis.min_value = 0
# Set the major unit
chart.value_axis.major_unit = 25.0
# Category(X) axis crosses at the maxinum value.
chart.value_axis.cross_type = CrossType.MAXIMUM
# Set he number of categories or series between tick-mark labels.
chart.category_axis.tick_label_spacing = 2
# do your business
# Saving the Excel file
workbook.save("book1.xlsx")

See Also