Python Interactive Graphing
using Plotly-Dash Library and Jupyter
Set up environment
For Python interactive graphing you will need to install a few python libraries. You can install them globally on your system or you can create a Conda environment specifically for efficient data analysis and graphing. If you choose the first option, follow all the instructions in the Install Requirements section except for creating and activating the Conda environment.
These libraries contains predefined functions that you can call on your own dataset to create customized graphs.
python=3.9 # a programming language that provides the environment for the following libraries pandas=1.4.0 # to import data from file or url, then manage data structure via DataFrame object plotly=5.6.0 # a library for creating customized interactive graphs plotly_express=0.4.1 # a high-level wrapper for Plotly (an alternative approach to Graph Objects) dash=2.1.0 # (optional) to add on-the-fly customization of the graphs via widgets dash_bio=1.0.1 # (optional) to have predefined types of traces for specific biology-related tasks kaleido # to export static images to any format jupyter # to have Jupyter Notebook (file menagement in the separate tab) jupyterlab>=3 # to have Jupyter Lab (next-generation user interface) ipywidgets>=7.6 # to display interactive graphs directly in the notebook jupyter-dash # to add widgets (sliders, buttons) to Plotly charts in JupyterLab
If you still don’t have a virtual environment manager for Python programming, start by installing Conda following the instructions in the Macbook Pro Installation → Install Developer Libraries tutorial.
Create virtual environment
conda create -n plotly python==3.9
pip install pandas==1.4.0 pip install plotly==5.6.0 pip install plotly_express==0.4.1 pip install dash==2.1.0 pip install dash_bio==1.0.1 pip install -U kaleido pip install jupyter pip install "jupyterlab>=3" "ipywidgets>=7.6" pip install jupyter-dash
conda activate plotly
Start Jupyter via Terminal
This will open a browser on a localhost to the URL of your Notebooks, by default http://127.0.0.1:8888.
Browse file system to enter your workdir. Then, in the top right corner, click on
New and select
Python 3 (ipykernel) option.
This will open an interactive notebook in a new tab in your browser where you can execute your first Python code.
The detailed tutorial of using Plotly Graphing Library via Jupyter notebook you can explore here. Below, you can learn basics, which allow you to run and customize with a success all pre-implemented examples available in the repository.
- Tutorial: Creating XY Scatter Plot
- Tutorial: Creating 1D Volcano Plot
- Tutorial: Creating Heatmap
- Tutorial: Creating Dendrogram
- RStudio: Data Processing & Plotting with R