Export pyvis graph as vector or .png image. Is there a way?
Asked Answered
E

2

8

I'm looking for a way to export a huge Graph generated with pyvis in to a vector graphic .svg or at least .png format. Is there a way to do it? So far I've only found the option to save / export as .html file.

Thanks in advance.

Expedite answered 19/10, 2021 at 10:53 Comment(0)
T
2

For me this worked:

  • save the graph to HTML file
  • open the HTML in a new tab
  • right-click -> save image as ...
Tapis answered 4/3, 2022 at 15:4 Comment(0)
G
0

def generate_png(url_file, name): from playwright.sync_api import sync_playwright

with sync_playwright() as p:
    for browser_type in [p.chromium]:
        browser = browser_type.launch()
        page = browser.new_page()
        file = open(url_file, "r").read()
        page.set_content(file, wait_until="load")
        page.wait_for_timeout(30000)
        page.screenshot(path=f'{name}.png', full_page=True)
        file.close()
        browser.close()
Greenshank answered 20/3 at 5:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.