Given a saved HTML file with an image (an output from Bokeh), how can I save it as a PNG file with a DPI of 300?
I found some answers to similar questions, but they don't seem to work for me. I think I need someone to explain the whole process (importing the needed package, where it needs to be located if applicable, and how to call it).
I've tried this after pip installing webkit2png:
import os
os.system("webkit2png" "texas.html")
I've also tried:
import subprocess
subprocess.call("webkit2png", "texas.html")
Thanks in advance!
As of Bokeh 0.12.6
, it is now possible to export PNG and SVG directly from
Python code.
Exporting PNGs looks like this
export_png(plot, filename="plot.png")
And exporting SVGs looks like this
plot.output_backend = "svg"
export_svgs(plot, filename="plot.svg")
There are some optional dependencies that need to be installed. You can find more information in the Exporting Plots section of the User Guide.
Currently, plots are saved at their native resolution, but in 0.12.7
you will be able to set the size.
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