Skip to main content

Axes

Axis defines a numeric range on a single plane (X or Y), that will be used to scale attached Series to the ChartXYs viewport.

Axis intervals

Axis intervals can be configured by axis.set_interval()

import lightningchart as lc

lc.set_license('my-license-key')

chart = lc.ChartXY()
x_axis = chart.get_default_x_axis()
y_axis = chart.get_default_y_axis()

x_axis.set_interval(start=0, end=1000)
y_axis.set_interval(start=-250, end=500)

Default interval

Custom default axis interval can be set by axis.set_default_interval()

import lightningchart as lc

lc.set_license('my-license-key')

chart = lc.ChartXY()
x_axis = chart.get_default_x_axis()

x_axis.set_default_interval(start=-100, end=100)

Interval restrictions

Various axis interval restrictions can be applied by axis.set_interval_restrictions()

import lightningchart as lc

lc.set_license('my-license-key')

chart = lc.ChartXY()

x_axis = chart.get_default_x_axis()
x_axis.set_interval_restrictions(
interval_min=10,
interval_max=100,
start_min=-25,
start_max=25,
end_min=25,
end_max=50
)

Scrolling axis

One of the most important features of LightningChart Python is smooth real-time visualization, i.e., visualization of a data set that is continuously receiving new data points.

In real-time monitoring use cases, there is often a scrolling axis (often Time axis) whose interval is progressively moving forward along with the incoming data. To achieve this, a progressive scroll strategy is used:

import lightningchart as lc

lc.set_license('my-license-key')

chart = lc.ChartXY()
axis = chart.get_default_x_axis()
axis.set_scroll_strategy('progressive')
axis.set_interval(start=0, end=60 * 1000, stop_axis_after=False) # 60 seconds as milliseconds

The progressive scroll strategy doesn't change size of axis interval (end - start, in the example case 60_000), but shifts the interval forward when new data comes in.

To use it, the set_interval() method is used in conjunction to configure the axis interval (important: remember to use stop_axis_after flag to prevent stopping the axis).

Logarithmic axes & multiple axes

ChartXY doesn't have a limit on number of axes. Additional axes can be created with chart.add_x_axis() and chart.add_y_axis(). Multiple Axes can be stacked on top of another, and axes can be positioned on either side of the chart (left, right, top, bottom)

import lightningchart as lc

lc.set_license('my-license-key')

chart = lc.ChartXY()

default_axis = chart.get_default_x_axis() # get the reference to the default x-axis
default_axis.dispose() # remove the default x-axis

custom_axis = chart.add_x_axis(
opposite=False,
axis_type='logarithmic', # Create a new axis of logarithmic type
base=10
)
custom_axis.set_interval(start=1, end=1000)
custom_axis.set_title('Logarithmic axis')
series = chart.add_line_series(x_axis=custom_axis)
series.add(x=[1, 10, 100, 1000], y=[5, 2, 7, 4])

chart.open()

Synchronized axes

Axes within ChartXY can be synchronized by chart.synchronize_axis_intervals(). This ensures that their interval is always the same.