Published
Edited
Jan 3, 2022
Importers
2 stars
Insert cell
Insert cell
intro = py`import pyvis.network #depends on both pyvis from ${micropipDependenciesPy} and micropip from ${packagesPy}

pyvis_graph = pyvis.network.Network(notebook=True)

pyvis_graph.add_node(0, label="foo", title="This is FOO", color="orange", size=9)
pyvis_graph.add_node(1, label="bar", title="That is BAR", color="blue", size=5)
pyvis_graph.add_node(2, label="baz", title="Here is BAZ", color="green", size=3)

pyvis_graph.add_edge(0, 1, label="xyzzy", color="gray")
pyvis_graph.add_edge(0, 2, label="fubar", color="red")

pyvis_graph.force_atlas_2based()
pyvis_graph.show("tmp.fig02.html")`
Insert cell
pyVisFrame(intro)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
kg = py`
import io
with io.open('ex2_0_tmp.ttl','w',encoding='utf8') as f:
f.write(${await FileAttachment("ex2_0_tmp.ttl").text()})
kg = ${kglab}.KnowledgeGraph().load_rdf("ex2_0_tmp.ttl")
kg
`
Insert cell
Insert cell
subgraph = py`${kglab}.SubgraphTensor(${kg})`
Insert cell
pyvis_graph = py`VIS_STYLE = {
"wtm": {
"color": "orange",
"size": 40,
},
"ind":{
"color": "blue",
"size": 30,
},
}

pyvis_graph = ${subgraph}.build_pyvis_graph(notebook=True, style=VIS_STYLE)
pyvis_graph.force_atlas_2based()
pyvis_graph.show("tmp.fig03.html")`
Insert cell
Insert cell
pyVisFrame(pyvis_graph)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
kglab = py`
#make completely sure pyvis is loaded first
import micropip
micropip.install("https://thadk.net/pyodide_packages/pyodide_18_1/pyvis-0.1.9-py2.py3-none-any.whl")

import kglab
# ${otherKglabDependencies} ${kglabDependency} ${micropipDependenciesPy}
kglab
`
Insert cell
py`dir(${kglab})`
Insert cell
py`repr(${kglab})`
Insert cell
Insert cell
import { py, pyodide, downloadPyoFile } from "@thadk/pyodide-18"
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more