Skip to main content
v2.2

Scatter Chart

Scatter charts can be created using ChartXY and Point Series. Bubble Chart can also be created using Point Series, by specifying unique point size values.

Scatter chartScatter chart

Creating Point Series

series = chart.add_point_series()

Adding Data

There are many different ways you can add data to a Point series. The most basic way is to specify two lists of numbers, one for X coordinates, and another for Y coordinates.

# Using x and y lists:
x_values = [0, 1, 2, 3]
y_values = [1, 3, 2, 4]
series.add(x_values, y_values)

Another common way of adding data is to read from a list of dictionaries/JSON-like objects:

# Using a list of dictionaries:
data_points = [
{'x': 0, 'y': 1},
{'x': 1, 'y': 3}
]
series.add(data=data_points)

Please refer to Adding Data to Charts section to see other available ways of adding data to a series.

Schema and Data Mapping

This section works the same as for Line series, to avoid duplication of guides, please refer to the section under Line

Customizing Point Appearance

Changing Point Color

Using individual point color:

import lightningchart as lc

series.set_point_color((255, 0, 0))
series.set_point_color('#FF0000')
series.set_point_color('red')

Using lookup table for point coloring:

chart = lc.ChartXY(title='ChartXY', theme=lc.Themes.Light)
series = chart.add_point_series()


x_values = [0, 1, 2, 3]
y_values = [2, 3, 5, 7]
series.add(x_values, y_values)

# Define a palette for the point coloring to interpolate between red, yellow, and green:
series.set_palette_point_coloring(
steps=[
{'value': 2, 'color': '#FF0000', 'label': 'Min'},
{'value': 4, 'color': (255, 255, 0)},
{'value': 7, 'color': 'green', 'label': 'Max'},
],
look_up_property='y',
interpolate=True,
)

# With formatted legend display:
series.set_palette_point_coloring(
steps=[
{'value': 0, 'color': '#0000FF'},
{'value': 100, 'color': '#FF0000'},
],
look_up_property='value',
formatter_precision=2, # Decimal places
formatter_unit='mag', # Unit suffix
formatter_scale=1.5, # Scale values
formatter_type='scientific', # 'standard', 'compact', 'engineering', 'scientific'
formatter_operation='floor', # 'none', 'round', 'ceil', 'floor'
)
Point seriesPoint series

Changing Point shape

series.set_point_shape('circle')

Available patterns include: "arrow", "circle", "cross", "diamond", "minus", "plus", "square", "star" and "triangle".

Changing Point size

series.set_point_size(5)

Changing Point rotation

series.set_point_rotation(45)

Changing Point stroke style

series.set_point_stroke_style(style='solid', thickness=2, color="#ff0000")

Enabling or disabling individual point color attributes

series.set_individual_point_color_enabled(True)

Custom Point and Video Styling

These methods allow you to customize the appearance of points by using images or videos.

Set Point Image Style

Sets the fill style of points using an image. The image can be provided as a local file path or a URL.

# Use an image from a local file as the point style:
series.set_point_image_style("D:/path/to/local_image.png")

# Or use an image from a URL:
series.set_point_image_style("https://example.com/image.jpg")
Point seriesPoint series

Set Custom Point Shape

Allows setting a custom shape for points by using an icon.

# Use an icon from a local file as the point style:
series.set_custom_point_shape("D:/path/to/local_icon.png")

# Or use an icon from a URL:
series.set_custom_point_shape("https://example.com/icon.jpg")
Point seriesPoint series

Set Point Video Style

Sets the point fill style to a video.

# Set a video style for points using a local video file:
series.set_point_video_style("D:/path/to/local_video.mp4")

# Or use a video from a URL with a different fit mode:
series.set_point_video_style("https://example.com/video.mp4")

Legend

Please see common legend section.

Examples

Link to the examples