Skip to content

Latest commit

 

History

History
67 lines (46 loc) · 1.66 KB

File metadata and controls

67 lines (46 loc) · 1.66 KB

Jupyter Support

As of version 0.7.0, Plotly.rs has native support for the EvCxR Jupyter Kernel.

Once you've installed the required packages you'll be able to run all the examples shown here as well as all the recipes in Jupyter Lab!

Tested against JupyterLab 4.4.7.

Installation

Install the plotly package and JupyterLab using pip or conda:

pip

pip install plotly jupyterlab

conda

conda install -c conda-forge plotly jupyterlab

No separate JupyterLab extension install is required — the plotly renderer is bundled with the plotly package (5.x+) and JupyterLab picks it up automatically.

Note: anywidget is required for Python's FigureWidget interactive features but is not needed for the Rust evcxr_display() path.

Next, install the EvCxR Jupyter Kernel:

cargo install evcxr_jupyter
evcxr_jupyter --install

Usage

Launch Jupyter Lab:

jupyter lab

Create a new notebook and select the Rust kernel. Add the plotly dependency and display a plot:

Cell 1

:dep plotly = "0.14"

Cell 2

use plotly::{Plot, Scatter};

let trace = Scatter::new(vec![1.0, 2.0, 3.0], vec![1.0, 4.0, 9.0]);
let mut plot = Plot::new();
plot.add_trace(trace);

plot.evcxr_display();

evcxr_display() works in both Jupyter Lab and Notebook. Alternatively you can leave the plot on the last line of a cell without a semicolon for the same effect.

You can find a full notebook example here.