{"spec_id":"line-timeseries","library":"makie","language":"julia","code":"# anyplot.ai\n# line-timeseries: Time Series Line Plot\n# Library: makie 0.21.9 | Julia 1.11.9\n# Quality: 85/100 | Created: 2026-09-05\n\nusing CairoMakie\nusing Colors\nusing Dates\nusing Random\n\nRandom.seed!(42)\n\n# --- Theme tokens ------------------------------------------------------------\nTHEME    = get(ENV, \"ANYPLOT_THEME\", \"light\")\nPAGE_BG  = THEME == \"light\" ? colorant\"#FAF8F1\" : colorant\"#1A1A17\"\nINK      = THEME == \"light\" ? colorant\"#1A1A17\" : colorant\"#F0EFE8\"\nINK_SOFT = THEME == \"light\" ? colorant\"#4A4A44\" : colorant\"#B8B7B0\"\nBRAND    = colorant\"#009E73\"  # Imprint palette position 1 — always first series\n\n# --- Data ----------------------------------------------------------------------\n# Daily average temperature readings across a full year, in degrees Celsius.\nstart_date = Date(2024, 1, 1)\nn_days = 365\ndates = start_date .+ Day.(0:(n_days - 1))\nday_offset = Float64.(Dates.value.(dates .- start_date))\n\nseasonal_cycle = 14.0 .+ 11.0 .* sin.(2π .* day_offset ./ 365 .- (π / 2))\ndaily_noise = randn(n_days) .* 2.2\ntemperature_c = seasonal_cycle .+ daily_noise\n\n# Smart tick locator: one tick per month, labeled with the abbreviated month name.\nmonth_starts = unique(Date.(year.(dates), month.(dates), 1))\ntick_positions = Float64.(Dates.value.(month_starts .- start_date))\ntick_labels = Dates.format.(month_starts, \"u\")\n\n# --- Plot ------------------------------------------------------------------------\ntitle_str = \"Average Daily Temperature (2024) · line-timeseries · julia · makie · anyplot.ai\"\nn_chars = length(title_str)\ntitle_fontsize = n_chars > 67 ? max(14, round(Int, 26 * 67 / n_chars)) : 26\n\npeak_idx = argmax(temperature_c)\npeak_x = day_offset[peak_idx]\npeak_y = temperature_c[peak_idx]\npeak_label = \"Peak: $(round(peak_y, digits=1))°C ($(Dates.format(dates[peak_idx], \"u d\")))\"\n\nfig = Figure(\n    size            = (1600, 900),\n    fontsize        = 14,\n    backgroundcolor = PAGE_BG,\n)\n\nax = Axis(\n    fig[1, 1];\n    title             = title_str,\n    titlesize         = title_fontsize,\n    titlecolor        = INK,\n    xlabel            = \"Month\",\n    ylabel            = \"Temperature (°C)\",\n    xlabelsize        = 14,\n    ylabelsize        = 14,\n    xlabelcolor       = INK,\n    ylabelcolor       = INK,\n    xticklabelsize    = 12,\n    yticklabelsize    = 12,\n    xticklabelcolor   = INK_SOFT,\n    yticklabelcolor   = INK_SOFT,\n    xtickcolor        = INK_SOFT,\n    ytickcolor        = INK_SOFT,\n    xticksvisible     = false,\n    yticksvisible     = false,\n    xticks            = (tick_positions, tick_labels),\n    backgroundcolor   = PAGE_BG,\n    topspinevisible   = false,\n    rightspinevisible = false,\n    leftspinecolor    = INK_SOFT,\n    bottomspinecolor  = INK_SOFT,\n    xgridcolor        = RGBAf(INK.r, INK.g, INK.b, 0.15),\n    ygridcolor        = RGBAf(INK.r, INK.g, INK.b, 0.15),\n    xminorgridvisible = false,\n    yminorgridvisible = false,\n)\n\nlines!(ax, day_offset, temperature_c; color = BRAND, linewidth = 2.5)\nylims!(ax, minimum(temperature_c) - 3, peak_y + 5)\n\n# Focal point: highlight the seasonal peak for a touch of data storytelling.\nscatter!(ax, [peak_x], [peak_y]; color = BRAND, markersize = 14, strokewidth = 2, strokecolor = PAGE_BG)\ntext!(\n    ax, peak_x, peak_y;\n    text   = peak_label,\n    color  = INK,\n    fontsize = 13,\n    align  = (:center, :bottom),\n    offset = (0, 8),\n)\n\n# --- Save --------------------------------------------------------------------\nsave(\"plot-$(THEME).png\", fig; px_per_unit = 2)\n"}