Skip to content

Commit

Permalink
README: add section 'usage on Jupyter notebooks' (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
mseri authored and LaurentMazare committed Jun 26, 2019
1 parent 3c377d9 commit 0ba8bf5
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,20 @@
# ocaml-matplotlib
Plotting for ocaml using matplotlib pyplot and object-orient apis.


## Use in Jupyter notebooks
To use in an `ocaml` `jupyter` notebook, you can add the following in you jupyter init script, or in a notebook cell.

```ocaml
open Matplotlib;;
let plot () =
let data = Mpl.plot_data `png in
ignore (Jupyter_notebook.display ~base64:true "image/png" data);;
let () =
Mpl.set_backend Agg;
Mpl.style_use "ggplot"
;;
```

Using `plot` in the notebook then flushes the current picture and displays it (no need for a temporary file, everything is in memory).

0 comments on commit 0ba8bf5

Please sign in to comment.