DerwenAI / kglab

Graph Data Science: an abstraction layer in Python for building knowledge graphs, integrated with popular graph libraries – atop Pandas, NetworkX, RAPIDS, RDFlib, pySHACL, PyVis, morph-kgc, pslpython, pyarrow, etc.
https://derwen.ai/docs/kgl/
MIT License
574 stars 65 forks source link

Auto adjust window size when visualizing the graph #257

Closed jli113 closed 2 years ago

jli113 commented 2 years ago

I'm submitting a

Current Behaviour:

subgraph tensor is too small when showing the graph

Expected Behaviour:

subgraph tensor will adjust window size when showing the graph

Steps to reproduce:

import kglab kg = kglab.KnowledgeGraph().load_rdf("tmp.ttl") VIS_STYLE = { "wtm": { "color": "orange", "size": 40, }, "ind":{ "color": "blue", "size": 30, }, } subgraph = kglab.SubgraphTensor(kg) pyvis_graph = subgraph.build_pyvis_graph(notebook=True, style=VIS_STYLE)

Snapshot:

Environment:

* python version 3.9.11 * pip version * OS details ubuntu 20.04.4 64
jli113 commented 2 years ago

change the line "pyvis_graph = pyvis.network.Network(notebook=notebook)" in subg.py after line 465 to, import pyautogui wid, hei= pyautogui.size() pyvis_graph = pyvis.network.Network(width='{}px'.format(wid), height='{}px'.format(hei), notebook=notebook)

ceteri commented 2 years ago

Hi @jli113 this look interesting.

For our library use overall, we're supporting more integrations for visualization than pyvis so the approach would need to be generalized.

The code shown above would work for the tutorial notebook for pyvis Do you have a PR that you can submit?

Thanks - paco

jli113 commented 2 years ago

It worked fine inside the notebook, but maybe too small when not using the notebook.