Skip to main content
v2.2

Basic principles

Let's look at a very basic XY data visualization use case to understand the most important concepts of LightningChart Python:

import lightningchart as lc

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

x = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
y = [2, 1, 4, 3, 6, 5, 8, 7, 10, 9]

chart = lc.ChartXY()
series = chart.add_line_series()
series.add(x, y)
chart.open()
  • Firstly, the lightningchart library must be imported. For convenience, import alias lc is used.
  • In order to display the charts, you must provide your personal license key with lc.set_license
  • Next, we define the data for this example, i.e., lists of x and y values.
  • To visualize this data, ChartXY is created and its reference is stored into a variable chart
  • We want to visualize the data as a line, so we create a line series for ChartXY with chart.add_line_series. We also save the series reference into variable series
  • x and y data points can be added to the series by series.add(x, y).
    • Some chart and series types have different APIs for adding data. See each features page for examples.
  • Finally, the chart can be displayed by chart.open().