Skip to content

Commit

Permalink
updated documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Giancarlo Perrone committed May 14, 2018
1 parent 573a15a commit 71289c7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
4 changes: 2 additions & 2 deletions pyvis/source/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ and run the following in the top-level directory:

.. code-block:: bash
$ pip install .
$ python setup.py install
.. _here: https://bitbucket.whidsc.net/projects/VIS/repos/pyvis/browse/pyvis
.. _here: https://github.com/WestHealth/pyvis/
31 changes: 16 additions & 15 deletions pyvis/source/tutorial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@ Getting started
---------------
All networks must be instantiated as a Network class instance

>>> from pyvis import network as nt
>>> net = nt.Network()
>>> from pyvis.network import Network
>>> net = Network()

Add nodes to the network
------------------------
>>> net.add_node(0, label="Node 0")
------------------------
>>> net.add_node(1, label="Node 1") # node id = 1 and label = Node 1
>>> net.add_node(2) # node id and label = 2

Expand All @@ -32,7 +31,10 @@ the node id will be used as a label.
Or add a list of nodes

>>> nodes = ["a", "b", "c", "d"]
>>> net.add_nodes(nodes)
>>> net.add_nodes(nodes) # node ids and labels = ["a", "b", "c", "d"]
>>> net.add_nodes("hello") # node ids and labels = ["h", "e", "l", "o"]

.. note:: :meth:`network.Network.add_nodes` accepts any iterable as long as the contents are strings or numerics

Node properties
---------------
Expand Down Expand Up @@ -88,11 +90,11 @@ An easy way to visualize and construct pyvis networks is to use `networkx
<https://networkx.github.io>`_ and use pyvis's built-in networkx helper
function to translate the graph.

>>> from pyvis import network as net
>>> from pyvis.network import Network
>>> import networkx as nx
>>> G = nx.complete_graph(10)
>>> nxg = net.Network()
>>> nxg.from_nx(G)
>>> nxg = nx.complete_graph(10)
>>> G = Network()
>>> G.from_nx(nxg)

.. note:: This method does not respect any properties nodes and edges may have on the networkx instance. Properties would need to reassigned through the pyvis layer.

Expand All @@ -114,10 +116,10 @@ The following code block is a minimal example of the capabilities of pyvis.

.. code-block:: python
from pyvis import network as net
from pyvis.network import Network
import pandas as pd
got_net = net.Network(height="100%", width="100%")
got_net = Network(height="100%", width="100%")
# set the physics layout of the network
got_net.barnes_hut()
Expand Down Expand Up @@ -162,10 +164,9 @@ Using pyviz within `Jupyter <https://jupyter.org>`_ notebook
------------------------------------------------------------

Pyviz supports `Jupyter <https://jupyter.org>`_ notebook embedding through the
use of the
:meth:`network.Network.prep_notebook` method. The network instance must be
"prepped" prior to visualization through the use of
:meth:`network.Network.prep_notebook` and :meth:`network.Network.show`.
use of the
:meth:`network.Network` contructor. The network instance must be
"prepped" during instantiation by supplying the `notebook=True` kwarg.
Example:

.. image:: jup.png
Expand Down

0 comments on commit 71289c7

Please sign in to comment.