Article.DataLibrary.Python.PlotlyChart
This repository demonstrate how to use Plotly Python library to plot chart on IPython environment.
Install / Use
/learn @LSEG-API-Samples/Article.DataLibrary.Python.PlotlyChartREADME
Plotting Financial Data Chart with Plotly Python
- Last update: March 2025
- Environment: Windows
- Compiler: Python
- Prerequisite: Workspace application with access to Data Library
<a id="overview"></a>Overview
With the rise of Data Scientists, Financial coders, or Traders (aka Citizen Developers), data visualization is a big part of how to present data, information, and its context to the readers (Financial team, Marketing team, etc.). The good data analysis itself cannot be used with a good graph representation.
The Matplotlib Pyplot is a de-facto library for making interactive plot and data visualization in the Python and Data Scientists world. However, the Matplotlib is a huge library that contains several interfaces, capabilities, and 1000+ pages of documents.
There are a lot of others alternative Plotting libraries such as Seaborn (which is a high-level interface of Matplotlib), Spotify's Chartify, Bokeh, Plotly Python, etc.
This example project demonstrates how to use the Plotly Python library to plot various types of graphs. The demo application uses data from LSEG Workspace platform via the LSEG Data Library for Python (Data Library version 2) as an example dataset.
<a id="plotly_intro"></a>Introduction to Plotly Python
Plotly Python is a free and open source interactive graphing library for Python. The library is built on top of plotly.js JavaScript library (GitHub). Both Plotly Python and Plotly JavaScript are part of Plotly's Dash and Chart Studio applications suites which provide interactively, scientific data visualization libraries/solutions for Data Scientists and Enterprise.
This Jupyter Notebook is focusing on the Plotly Python open-source library versions 6.0.1 and 5.4.0 (on CodeBook) only.
import plotly.express as px
fig = px.line(x=["a","b","c"], y=[1,3,2], title="sample figure")
fig.show()

<a id="rdp_lib"></a>Introduction to the Data Library for Python
The LSEG Data Library for Python (aka Data Library version 2) provides a set of ease-of-use interfaces offering coders uniform access to the breadth and depth of financial data and services available on the Workspace, RDP, and Real-Time Platforms. The API is designed to provide consistent access through multiple access channels and target both Professional Developers and Financial Coders. Developers can choose to access content from the desktop, through their deployed streaming services, or directly to the cloud. With the Data Library, the same Python code can be used to retrieve data regardless of which access point you choose to connect to the platform.

The Data Library are available in the following programming languages:
For more deep detail regarding the Data Library for Python, please refer to the following articles and tutorials:
Disclaimer
This project is based on Data Library Python versions 2.0.1 using the Desktop Session only.
<a id="prerequisite"></a>Prerequisite
This example requires the following dependencies software and libraries.
- LSEG Workspace application with access to Data Library.
- Python version 3.10 or 3.11 (Command or MiniConda distribution/package manager can be used as well).
- JupyterLab application.
- Internet connection.
Please contact your LSEG's representative to help you to access Workspace credentials. You can generate/manage the AppKey by follow the steps in Data Library for Python Quick Start page.
<a id="application_files"></a>Application Files
This example project contains the following files and folders
- notebook/plotly_ld.ipynb: The example JupyterLap application file.
- requirements.txt: The project dependencies configuration file.
- images: Project images folder.
- LICENSE.md: Project's license file.
- README.md: Project's README file.
<a id="running_notebook"></a>How to run this example with the Classic Jupyter Notebook
Please note that the Workspace application integrates a Data API proxy that acts as an interface between the Eikon Data API Python library and the Eikon Data Platform. For this reason, the Workspace application must be running when you use the Eikon Data API Python library.
The first step is to unzip or download the example project folder into a directory of your choice, then set up a Conda environment for running the application with the steps below.
-
Open a Command Prompt and go to the project's folder
-
Run the following command in a Command Prompt application to create the Python environment named plotly_chart for the project.
$>python -m venv plotly_chart -
Once the environment is created, activate an environment named
plotly_chartwith this command in a Command Prompt.$>plotly_chart\Scripts\activate -
Once an environment is activated, run the following command to install all dependencies in the plotly_chart environment
(plotly_chart) $>pip install -r requirements.txt -
Go to project's notebook folder and input your Workspace App Key a file name
lseg-data.config.jsonwith the following content{ "logs": {...}, "sessions": { "default": "desktop.workspace", "desktop": { "workspace": { "app-key": "YOUR APP KEY GOES HERE!" } } } } -
In a current Command Prompt, go to the project's notebook folder. Run the following command to start the JupyterLab application.
(plotly_chart) $>notebook>jupyter notebook -
JupyterLab will open the web browser and will go to the notebook home page.
-
Open the plotly_ld.ipynb.ipynb Notebook document, then go through each notebook cell.

<a id="running_codebook"></a>How to run this example with the CodeBook
If you are Workspace user, you can access CodeBook, the cloud-hosted Jupyter Notebook development environment for Python scripting from the application. The CodeBook is natively available in Workspace as an app (no installation required!!), providing access to LSEG APIs that are already pre-installed on the cloud.
The CodeBook also contains Plotly version 5.4.0. You can upload the plotly_ld.ipynb.ipynb notebook application to the CodeBook with the following steps:
-
In the Workspace application, search for the
CodeBook(orCODEBK).
-
Once the CodeBook finished initialize, create a new folder name plotly


-
Enter the plotly folder, and click the upload button and select plotly_ld.ipynb.ipynb notebook file.

-
Then open the plotly_ld.ipynb.ipynb notebook file

-
On this init session cell, change it to
# CodeBook ld.open_session()
<a id="conclusion"></a>Conclusion
Data visualization is the first impression of data analysis for the readers. Data Scientists, Financial coders, and Developers take time on the data visualization process longer than the time they use for getting the data. It means the data visualization/chart library need to be easy to use, flexible and have a good document.
Plotly Python provides both ease-of-use/high-level and low-level interface for supporting a wide range of Developers' skills. Developers can pick the Plotly Chart object (line, bar, scatter, candlestick, etc) that match their requirements, check the Plotly example code and community page to create a nice chart with readable and easy to maintain source code.
When compare to the Matplotlib-Pyplot (whic
Languages
Security Score
Audited on May 20, 2025
