Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

exporting pdf and png #621

Open
wangjiawen2013 opened this issue Dec 20, 2024 · 3 comments
Open

exporting pdf and png #621

wangjiawen2013 opened this issue Dec 20, 2024 · 3 comments

Comments

@wangjiawen2013
Copy link

Hi,
How to export the pygraphistry visulalization to png/pdf/svg/jpeg ?

@qui8t
Copy link

qui8t commented Dec 20, 2024

I am surprised there is no documentation on this.

There is this PDF, which results in visualization that is no where near graphistry visualization, and should not be considered as a way of saving the plots in png/jpg.

edges = pd.DataFrame({'s': ['a','b','c','d'], 'd': ['b','c','d','e']})
g = graphistry.edges(edges, 's', 'd')
g.layout_graphviz(
  'dot',
  render_to_disk=True,
  path='graph.png',
  format='png'
)

@lmeyerov
Copy link
Contributor

Yes, it is useful to distinguish layout from rendering -- g.layout_graphviz().plot() would use the graphviz dot engine to layout and then graphistry to render (webgl iframe), while g.layout_graphviz(render_to_disk=True) would use the graphviz for both layout & render

A bit manual, but from a graphistry viz, you can either:

  • render & manually screenshot
  • render, and then right-click to save the html dom canvas layer. It will not save the labels. You may need to 'delete' from the dom tree the click interaction layer.

We had an experimental backend renderer that would return a .svg, and experiments with serverside rendering, but the quality was not as good. A direction we have been considering is:

  • In-tool, use the browser's native MediaDevices.getDisplayMedia() for a full fidelity screenshot, potentially with an option to hide UI chrome
  • API support:
    • JavaScript: Allow embedding frames to gain access to a pixel buffer representing the screenshot, or trigger the download action
    • Python: Enable Python sessions (.ipynb, ...) to send commands to a live browser session and get data back, session as the screenshot buffer
  • Revisit serverside rendering, with a ~browser in the server for full-fidelity

I'm curious how those line up with your thinking and your use cases, or you're thinking something else? And any sense of priority level?

@lmeyerov lmeyerov added the p4 label Dec 24, 2024
@qui8t
Copy link

qui8t commented Dec 25, 2024

Those are good workarounds! When I right-click save the html, I get a main.???.js.download file, is there anyway to open-and-save this as a png file?

I need to save a screenshot of a graph for scientific paper submission. I am currently including a screenshot from the browser, but that is very low resolution, so I would need to a get a much higher resolution for camera-ready.

We had an experimental backend renderer that would return a .svg, and experiments with serverside rendering, but the quality was not as good.

Glad you're already thinking of a good solution. Since I need to generate graphs for multiple data sources, and need to render them with same config, this would work best for me:

  • post data and render setting (e.g., center magnet, compact layout, edge opacity);
  • get an SVG or a PNG in at least 600dpi back.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants