Skip to content

Commit dc82674

Browse files
authored
Update jupyter_support.md (#147)
Update example (original would not build for me) Correct links to examples in the repo Fix small typo at the end (Plot::noteboo_display -> Plot::notebook_display)
1 parent b314b80 commit dc82674

File tree

1 file changed

+16
-17
lines changed

1 file changed

+16
-17
lines changed

docs/book/src/fundamentals/jupyter_support.md

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -70,41 +70,40 @@ jupyter lab
7070
create a new notebook and select the `Rust` kernel. Then create the following three cells and execute them in order:
7171

7272
```shell script
73+
:dep ndarray = "0.15.6"
7374
:dep plotly = { version = ">=0.7.0" }
74-
:dep itertools-num = "0.1.3"
7575
```
7676
7777
```rust
78+
extern crate ndarray;
7879
extern crate plotly;
7980
extern crate rand_distr;
80-
extern crate itertools_num;
81-
extern crate itertools;
8281
```
8382
8483
```rust
85-
use itertools_num::linspace;
86-
use plotly::common::{
87-
ColorScale, ColorScalePalette, DashType, Fill, Font, Line, LineShape, Marker, Mode, Title,
88-
};
89-
use plotly::layout::{Axis, BarMode, Layout, Legend, TicksDirection};
90-
use plotly::{Bar, NamedColor, Plot, Rgb, Rgba, Scatter};
91-
use rand_distr::{Distribution, Normal, Uniform};
84+
use ndarray::Array;
85+
use plotly::common::Mode;
86+
use plotly::layout::{Layout};
87+
use plotly::{Plot, Scatter};
88+
use rand_distr::{num_traits::Float, Distribution};
9289
```
9390
9491
Now we're ready to start plotting!
9592
9693
```rust
97-
let n: usize = 100;
98-
let t: Vec<f64> = linspace(0., 10., n).collect();
99-
let y: Vec<f64> = t.iter().map(|x| x.sin()).collect();
94+
let x0 = Array::linspace(1.0, 3.0, 200).into_raw_vec();
95+
let y0 = x0.iter().map(|v| *v * (v.powf(2.)).sin() + 1.).collect();
10096
101-
let trace = Scatter::new(t, y).mode(Mode::Markers);
97+
let trace = Scatter::new(x0, y0);
10298
let mut plot = Plot::new();
10399
plot.add_trace(trace);
104-
let layout = Layout::new().height(800);
100+
101+
let layout = Layout::new().height(525);
105102
plot.set_layout(layout);
103+
106104
plot.lab_display();
105+
format!("EVCXR_BEGIN_CONTENT application/vnd.plotly.v1+json\n{}\nEVCXR_END_CONTENT", plot.to_json())
107106
```
108-
For Jupyter Lab there are two ways to display a plot in the `EvCxR` kernel, either have the plot object be in the last line without a semicolon or directly invoke the `Plot::lab_display` method on it; both have the same result. You can also find an example notebook [here](https://github.com/igiagkiozis/plotly/blob/master/plotly/examples/jupyter_lab_examples.ipynb) that will periodically be updated with examples.
107+
For Jupyter Lab there are two ways to display a plot in the `EvCxR` kernel, either have the plot object be in the last line without a semicolon or directly invoke the `Plot::lab_display` method on it; both have the same result. You can also find an example notebook [here](https://github.com/igiagkiozis/plotly/blob/master/examples/jupyter/jupyter_lab.ipynb) that will periodically be updated with examples.
109108
110-
The process for Jupyter Notebook is very much the same with one exception; the `Plot::noteboo_display` method must be used to display the plot. You can find an example notebook [here](https://github.com/igiagkiozis/plotly/blob/master/plotly/examples/jupyter_notebook_examples.ipynb)
109+
The process for Jupyter Notebook is very much the same with one exception; the `Plot::notebook_display` method must be used to display the plot. You can find an example notebook [here](https://github.com/igiagkiozis/plotly/blob/master/examples/jupyter/jupyter_notebook.ipynb)

0 commit comments

Comments
 (0)