Visualization

pybel_tools.visualization.to_html(graph, color_map=None)[source]

Creates an HTML visualization for the given JSON representation of a BEL graph

Parameters:
  • graph (pybel.BELGraph) – A BEL graph
  • color_map (dict) – A dictionary from PyBEL internal node functions to CSS color strings like #FFEE00. Defaults to default_color_map
Returns:

HTML string representing the graph

Return type:

str

pybel_tools.visualization.to_html_file(graph, file, color_map=None)[source]

Writes the HTML visualization to a file or file-like

Parameters:
  • graph (pybel.BELGraph) – A BEL graph
  • color_map (dict) – A dictionary from PyBEL internal node functions to CSS color strings like #FFEE00. Defaults to default_color_map
  • file (file) – A writable file or file-like
pybel_tools.visualization.to_html_path(graph, path, color_map=None)[source]

Writes the HTML visualization to a file specified by the file path

Parameters:
  • graph (pybel.BELGraph) – A BEL graph
  • color_map (dict) – A dictionary from PyBEL internal node functions to CSS color strings like #FFEE00. Defaults to default_color_map
  • path (str) – The file path
pybel_tools.visualization.to_jupyter(graph, width=1000, height=650, color_map=None, replace_cnames=False)[source]

Displays the 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 (pybel.BELGraph) – A BEL graph
  • width (int) – The width of the visualization window to render
  • height (int) – The height of the visualization window to render
  • color_map (dict) – A dictionary from PyBEL internal node functions to CSS color strings like #FFEE00. Defaults to default_color_map
Returns:

An IPython notebook Javascript object

Return type:

IPython.display.Javascript

pybel_tools.visualization.to_jupyter_str(graph, width=1000, height=650, color_map=None, replace_cnames=False)[source]

Returns the string to be javascript-ified by the Jupyter notebook function IPython.display.Javascript

Parameters:
  • graph (pybel.BELGraph) – A BEL graph
  • width (int) – The width of the visualization window to render
  • height (int) – The height of the visualization window to render
  • color_map (dict) – A dictionary from PyBEL internal node functions to CSS color strings like #FFEE00. Defaults to default_color_map
Returns:

The javascript string to turn into magic

Return type:

str