{"spec_id":"line-stepwise","library":"seaborn","language":"python","code":"\"\"\" anyplot.ai\nline-stepwise: Step Line Plot\nLibrary: seaborn 0.13.2 | Python 3.13.13\nQuality: 90/100 | Updated: 2026-05-13\n\"\"\"\n\nimport os\n\nimport matplotlib.pyplot as plt\nimport numpy as np\nimport seaborn as sns\n\n\n# Theme tokens\nTHEME = os.getenv(\"ANYPLOT_THEME\", \"light\")\nPAGE_BG = \"#FAF8F1\" if THEME == \"light\" else \"#1A1A17\"\nELEVATED_BG = \"#FFFDF6\" if THEME == \"light\" else \"#242420\"\nINK = \"#1A1A17\" if THEME == \"light\" else \"#F0EFE8\"\nINK_SOFT = \"#4A4A44\" if THEME == \"light\" else \"#B8B7B0\"\nBRAND = \"#009E73\"\n\n# Set seaborn theme BEFORE creating figure\nsns.set_theme(\n    style=\"ticks\",\n    rc={\n        \"figure.facecolor\": PAGE_BG,\n        \"axes.facecolor\": PAGE_BG,\n        \"axes.edgecolor\": INK_SOFT,\n        \"axes.labelcolor\": INK,\n        \"text.color\": INK,\n        \"xtick.color\": INK_SOFT,\n        \"ytick.color\": INK_SOFT,\n        \"grid.color\": INK,\n        \"grid.alpha\": 0.10,\n    },\n)\n\n# Data - Stock price stepping over trading days\nnp.random.seed(42)\ndays = np.arange(0, 31)\n# Simulate intraday price with discrete closing steps\nbase_price = np.array(\n    [\n        150.00,\n        150.00,\n        150.00,\n        152.50,\n        152.50,\n        152.50,\n        155.00,\n        155.00,\n        155.00,\n        153.25,\n        153.25,\n        153.25,\n        156.75,\n        156.75,\n        156.75,\n        158.50,\n        158.50,\n        159.25,\n        159.25,\n        159.25,\n        161.00,\n        161.00,\n        161.00,\n        159.50,\n        159.50,\n        162.00,\n        162.00,\n        162.00,\n        164.50,\n        164.50,\n        163.75,\n    ]\n)\n\n# Create figure\nfig, ax = plt.subplots(figsize=(16, 9))\n\n# Step line plot using seaborn lineplot with drawstyle\nsns.lineplot(\n    x=days,\n    y=base_price,\n    ax=ax,\n    drawstyle=\"steps-post\",\n    linewidth=3,\n    color=BRAND,\n    marker=\"o\",\n    markersize=8,\n    markerfacecolor=BRAND,\n    markeredgecolor=PAGE_BG,\n    markeredgewidth=1,\n)\n\n# Style\nax.set_xlabel(\"Trading Day\", fontsize=20, color=INK)\nax.set_ylabel(\"Stock Price ($)\", fontsize=20, color=INK)\nax.set_title(\"line-stepwise · seaborn · anyplot.ai\", fontsize=24, fontweight=\"medium\", color=INK)\nax.tick_params(axis=\"both\", labelsize=16, colors=INK_SOFT)\n\n# Set axis limits\nax.set_xlim(-1, 30)\nax.set_ylim(145, 170)\n\n# Remove spines\nax.spines[\"top\"].set_visible(False)\nax.spines[\"right\"].set_visible(False)\nfor s in (\"left\", \"bottom\"):\n    ax.spines[s].set_color(INK_SOFT)\n\n# Grid - subtle y-axis only\nax.yaxis.grid(True, alpha=0.10, linewidth=0.8, color=INK)\n\nplt.tight_layout()\nplt.savefig(f\"plot-{THEME}.png\", dpi=300, bbox_inches=\"tight\", facecolor=PAGE_BG)\n"}