Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 33 additions & 19 deletions plots/sn-curve-basic/implementations/python/highcharts.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
""" anyplot.ai
sn-curve-basic: S-N Curve (Wöhler Curve)
Library: highcharts unknown | Python 3.13.13
Quality: 87/100 | Updated: 2026-05-20
Quality: 89/100 | Updated: 2026-05-20
"""

import os
Expand All @@ -15,6 +15,7 @@
from highcharts_core.options import HighchartsOptions
from highcharts_core.options.series.area import LineSeries
from highcharts_core.options.series.scatter import ScatterSeries
from PIL import Image
from selenium import webdriver
from selenium.webdriver.chrome.options import Options

Expand Down Expand Up @@ -73,10 +74,11 @@
"height": 1800,
"backgroundColor": PAGE_BG,
"style": {"fontFamily": "Arial, sans-serif", "color": INK},
"marginBottom": 120,
"marginBottom": 140,
"marginLeft": 150,
"marginRight": 80,
"marginTop": 100,
"plotBorderWidth": 0,
}

chart.options.title = {
Expand All @@ -92,7 +94,7 @@
"color": "rgba(213,94,0,0.07)",
"label": {
"text": "Low-Cycle Fatigue",
"style": {"fontSize": "32px", "color": INK_SOFT},
"style": {"fontSize": "36px", "color": INK_SOFT},
"align": "center",
"verticalAlign": "top",
"y": 30,
Expand All @@ -104,7 +106,7 @@
"color": "rgba(0,114,178,0.05)",
"label": {
"text": "High-Cycle Fatigue",
"style": {"fontSize": "32px", "color": INK_SOFT},
"style": {"fontSize": "36px", "color": INK_SOFT},
"align": "center",
"verticalAlign": "top",
"y": 30,
Expand All @@ -116,7 +118,7 @@
"color": "rgba(0,158,115,0.06)",
"label": {
"text": "Infinite Life",
"style": {"fontSize": "32px", "color": INK_SOFT},
"style": {"fontSize": "36px", "color": INK_SOFT},
"align": "center",
"verticalAlign": "top",
"y": 30,
Expand Down Expand Up @@ -151,40 +153,40 @@
"plotLines": [
{
"value": ultimate_strength,
"color": "#E53935",
"color": "#CC79A7",
"width": 4,
"dashStyle": "Dash",
"label": {
"text": f"Ultimate Strength ({ultimate_strength} MPa)",
"align": "right",
"style": {"fontSize": "34px", "color": "#E53935", "fontWeight": "bold"},
"x": -10,
"align": "left",
"style": {"fontSize": "34px", "color": "#CC79A7", "fontWeight": "bold"},
"x": 10,
},
"zIndex": 3,
},
{
"value": yield_strength,
"color": "#FB8C00",
"color": "#E69F00",
"width": 4,
"dashStyle": "Dash",
"label": {
"text": f"Yield Strength ({yield_strength} MPa)",
"align": "right",
"style": {"fontSize": "34px", "color": "#FB8C00", "fontWeight": "bold"},
"x": -10,
"align": "left",
"style": {"fontSize": "34px", "color": "#E69F00", "fontWeight": "bold"},
"x": 10,
},
"zIndex": 3,
},
{
"value": endurance_limit,
"color": "#43A047",
"color": "#56B4E9",
"width": 4,
"dashStyle": "Dash",
"label": {
"text": f"Endurance Limit ({endurance_limit} MPa)",
"align": "right",
"style": {"fontSize": "34px", "color": "#43A047", "fontWeight": "bold"},
"x": -10,
"align": "left",
"style": {"fontSize": "34px", "color": "#56B4E9", "fontWeight": "bold"},
"x": 10,
},
"zIndex": 3,
},
Expand All @@ -201,7 +203,7 @@
"verticalAlign": "top",
"layout": "vertical",
"x": -60,
"y": 100,
"y": 140,
}

chart.options.plot_options = {
Expand Down Expand Up @@ -253,16 +255,28 @@
temp_path = f.name

chrome_options = Options()
chrome_options.add_argument("--headless")
chrome_options.add_argument("--headless=new")
chrome_options.add_argument("--no-sandbox")
chrome_options.add_argument("--disable-dev-shm-usage")
chrome_options.add_argument("--disable-gpu")
chrome_options.add_argument("--hide-scrollbars")
chrome_options.add_argument("--window-size=3200,1800")

driver = webdriver.Chrome(options=chrome_options)
# CDP override makes the viewport authoritative; --window-size alone is eaten by Chrome chrome
driver.execute_cdp_cmd(
"Emulation.setDeviceMetricsOverride", {"width": 3200, "height": 1800, "deviceScaleFactor": 1, "mobile": False}
)
driver.get(f"file://{temp_path}")
time.sleep(5)
driver.save_screenshot(f"plot-{THEME}.png")
driver.quit()

Path(temp_path).unlink()

# PIL safety net: pin to exact 3200×1800 in case of ±1-2 px rounding
_img = Image.open(f"plot-{THEME}.png").convert("RGB")
if _img.size != (3200, 1800):
_norm = Image.new("RGB", (3200, 1800), PAGE_BG)
_norm.paste(_img, ((3200 - _img.size[0]) // 2, (1800 - _img.size[1]) // 2))
_norm.save(f"plot-{THEME}.png")
Loading