PyBEL-Jupyter¶
A PyBEL extension for Jupyter notebooks.
Installation¶
pybel_jupyter
can be installed easily from PyPI with the following
code in your favorite terminal:
$ pip install pybel-jupyter
or from the latest code on GitHub with:
$ pip install git+https://github.com/pybel/pybel-jupyter.git
Getting Started¶
Inside a Jupyter notebook, run the following code at the end of the cell to get an interactive visualization:
>>> from pybel.examples import sialic_acid_graph
>>> from pybel_jupyter import to_jupyter
>>> to_jupyter(sialic_acid_graph)
-
pybel_jupyter.
to_html
(graph, color_map=None)[source]¶ Create an HTML visualization for the given JSON representation of a BEL graph.
-
pybel_jupyter.
to_html_file
(graph, file, color_map=None)[source]¶ Write the HTML visualization to a file or file-like.
-
pybel_jupyter.
to_jupyter
(graph, width=1000, height=650, color_map=None)[source]¶ Display a BEL graph inline in a Jupyter notebook.
To use successfully, make run as the last statement in a cell inside a Jupyter notebook.
- Parameters
graph (
BELGraph
) – A BEL graphwidth (
int
) – The width of the visualization window to renderheight (
int
) – The height of the visualization window to rendercolor_map (
Optional
[Mapping
[str
,str
]]) – A dictionary from PyBEL internal node functions to CSS color strings like #FFEE00. Defaults todefault_color_map
- Returns
An IPython notebook Javascript object
- Return type
IPython.display.Javascript
-
pybel_jupyter.
to_jupyter_str
(graph, width=1000, height=650, color_map=None)[source]¶ Return the string to be javascript-ified by the Jupyter notebook function
IPython.display.Javascript
.- Parameters
graph (
BELGraph
) – A BEL graphwidth (
int
) – The width of the visualization window to renderheight (
int
) – The height of the visualization window to rendercolor_map (
Optional
[Mapping
[str
,str
]]) – A dictionary from PyBEL internal node functions to CSS color strings like #FFEE00. Defaults todefault_color_map
- Return type
- Returns
The javascript string to turn into magic