Jupyter Lab
Table of Contents
Software setup based on Data Crayon's "Setup Anaconda, Jupyter, and Rust" but without the python environments or any *conda stuff. I just want to run rust and display things nicely.
Install the things (jupyter lab, plotly, rust notebook kernel)
Fetch jupyter lab from pip
pip3 install jupyterlab
Add plotly to the jupyter lab install (useful for graphs)
pip3 install plotly jupyter labextension install jupyterlab-plotly
Install the rust language kernel
cargo install evcxr_jupyter
Add the rust kernel to the jupyter notebook
evcxr_jupyter --install
Install a C language kernel
pip3 install jupyter-c-kernel
Add the C kernel to jupyter
install_c_kernel --user
Get some vim bindings for the editor
Jupyter lab has it's own key map setting, but I think this has additional features. Updated fork for jupyterlab 2.x.
jupyter labextension install @axlair/jupyterlab_vim
Run it
This runs the lab server and opens a URL to it. There should be a Rust icon under the notebook option if all went well.
jupyter lab
A Plotly Example with Rust
Based on this Data Crayon Guide and this Plotly.rs documentation. This draws a simple graph using a couple cells. Using the newer plotly version allows plotting with lab_display()
.
:dep plotly = {version = ">=0.6.0"} extern crate plotly; use plotly::{Plot, Scatter}; use plotly::common::{Mode}; use std::fs;
let trace1 = Scatter::new(vec![1, 2, 3, 4], vec![10, 15, 13, 17]) .name("trace1") .mode(Mode::Markers); let trace2 = Scatter::new(vec![2, 3, 4, 5], vec![16, 5, 11, 9]) .name("trace2") .mode(Mode::Lines); let trace3 = Scatter::new(vec![1, 2, 3, 4], vec![12, 9, 15, 12]).name("trace3"); let mut plot = Plot::new(); plot.add_trace(trace1); plot.add_trace(trace2); plot.add_trace(trace3); plot.lab_display();