I am using Pyvis to visualize big network graphs. I would like to generate graphs with certain headings and then save them as jpg or png images. However, I don't see any such option in the documentation. There is a heading parameter for the class Network, but it generates a heading for the HTML file and not for the interactive element of the graph.
from pyvis import network as net
from IPython.core.display import display, HTML
g=net.Network(height='400px', width='50%',heading='Graph')
g.add_node(1)
g.add_node(2)
g.add_node(3)
g.add_edge(1,2)
g.add_edge(2,3)
g.show('example.html')
display(HTML('example.html'))
generates this graph that I have screenshot below.

How can I change the Graph heading to be in the box containing the graph, and can I saw this as a png or jpg image?
I think this i not possible with pyvis since the network object cant not contain text. But you can add headlines or text directly above and below your graph by adding a headline and/or paragrah element to your html document.
<body>
<div class="card" style="width: 100%">
<h1>headline above div with id = "mynetwork"</h1>
<p>text above div with id = "mynetwork"</p>
<div id="mynetwork" class="card-body"></div>
<p>text below div with id = "mynetwork"</p>
</div>
...
</body
The headline and text will appear like this
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With