I am using Plotly offline to generate graph in python.
As per the documentation below,
https://plot.ly/python/offline/
Here is my code, which perfec
You can automate PhantomJS to save a screenshot with exactly the same width and height as the original image would be when it is downloaded by opening the browser.
Here is the code:
import plotly.offline as offline
from selenium import webdriver
offline.plot({'data': [{'y': [4, 2, 3, 4]}],
'layout': {'title': 'Test Plot',
'font': dict(size=12)}},
image='svg', auto_open=False, image_width=1000, image_height=500)
driver = webdriver.PhantomJS(executable_path="phantomjs.exe")
driver.set_window_size(1000, 500)
driver.get('temp-plot.html')
driver.save_screenshot('my_plot.png')
#Use this, if you want a to embed this .png in a HTML file
#bs_img = driver.get_screenshot_as_base64()