vegas-viz / Vegas

The missing MatPlotLib for Scala + Spark
MIT License
730 stars 98 forks source link

Equivalent to matplotlib's `savefig` ? #129

Open andb0t opened 6 years ago

andb0t commented 6 years ago

Hi, I browsed the repo and googled but couldn't find if there is an option equivalent to matplotlib's savefig. I need my code to run without X server and produce the plots as pdf or png. Does this option exist?

LelandBarnard commented 6 years ago

I am also looking for this feature. Does anyone have any suggestions?

andb0t commented 6 years ago

FYI: I solved it by running an Xserver (in my case Xming for Windows Subsystem for Linux (WSL))

You can find my implementation here: click

oshikiri commented 6 years ago

FYI: As an experiment, I added the following code to WindowRenderer#show(), but it output a white blank png.

val image = window.webView.snapshot(new SnapshotParameters(), null)
val bufferedImage = SwingFXUtils.fromFXImage(image, null)
ImageIO.write(bufferedImage, "png", new File("output.png"))

javafx may not support such a use case? cf. https://stackoverflow.com/a/23444861/9625883