diff --git a/plots/highcharts/scatter/scatter-basic/default.py b/plots/highcharts/scatter/scatter-basic/default.py index 7ef004bc24..4c75cbc4d7 100644 --- a/plots/highcharts/scatter/scatter-basic/default.py +++ b/plots/highcharts/scatter/scatter-basic/default.py @@ -12,6 +12,7 @@ from highcharts_core.chart import Chart from highcharts_core.options import HighchartsOptions from highcharts_core.options.series.scatter import ScatterSeries +from PIL import Image from selenium import webdriver from selenium.webdriver.chrome.options import Options @@ -98,9 +99,14 @@ driver.get(f"file://{temp_path}") time.sleep(5) -# Screenshot the container element directly for exact dimensions -container = driver.find_element("id", "container") -container.screenshot("plot.png") +# Screenshot the full window and crop to exact dimensions +driver.save_screenshot("plot_raw.png") driver.quit() +# Crop to exact dimensions (4800 x 2700) +with Image.open("plot_raw.png") as img: + cropped = img.crop((0, 0, 4800, 2700)) + cropped.save("plot.png") +Path("plot_raw.png").unlink() + Path(temp_path).unlink()