Examples

The repository ships small runnable scripts under examples that demonstrate typical SignalPlot patterns. For rendered figures, see Gallery.

Time series line

examples/time_series_line.py
"""Time series line plot example for SignalPlot."""

from __future__ import annotations

import numpy as np
import matplotlib.pyplot as plt

import signalplot as sp


def main() -> None:
    sp.apply()

    rng = np.random.default_rng(0)
    dates = np.arange(0, 24)
    values = np.cumsum(rng.normal(size=dates.size))

    plt.figure()
    plt.plot(dates, values, color="black", linewidth=1.5)
    plt.title("Monthly electricity demand")

    sp.save("time_series.png")
    plt.show()


if __name__ == "__main__":
    main()


Multiple line comparison

examples/multi_line_comparison.py
"""Multiple line comparison example for SignalPlot."""

from __future__ import annotations

import numpy as np
import matplotlib.pyplot as plt

import signalplot as sp


def main() -> None:
    sp.apply()

    rng = np.random.default_rng(1)
    dates = np.arange(0, 24)
    region_a = np.cumsum(rng.normal(size=dates.size))
    region_b = np.cumsum(rng.normal(size=dates.size)) + 5

    plt.figure()
    plt.plot(dates, region_a, color="0.6", linewidth=1.0)
    plt.plot(dates, region_b, color="black", linewidth=1.5)
    plt.title("Regional demand comparison")

    sp.save("multi_line.png")
    plt.show()


if __name__ == "__main__":
    main()


Scatter relationship

examples/scatter_relationship.py
"""Scatter-plot relationship example for SignalPlot."""

from __future__ import annotations

import numpy as np
import matplotlib.pyplot as plt

import signalplot as sp


def main() -> None:
    sp.apply()

    rng = np.random.default_rng(2)
    x = rng.normal(0, 1, 250)
    y = 0.6 * x + rng.normal(0, 0.7, 250)

    plt.figure()
    plt.scatter(x, y, s=20, color="black")
    plt.title("Load versus temperature")

    sp.save("scatter.png")
    plt.show()


if __name__ == "__main__":
    main()


Histogram distribution

examples/histogram_distribution.py
"""Histogram distribution example for SignalPlot."""

from __future__ import annotations

import numpy as np
import matplotlib.pyplot as plt

import signalplot as sp


def main() -> None:
    sp.apply()

    rng = np.random.default_rng(3)
    values = rng.normal(size=1000)

    plt.figure()
    plt.hist(values, bins=30, color="0.7", edgecolor="black")
    plt.title("Distribution of daily demand")

    sp.save("histogram.png")
    plt.show()


if __name__ == "__main__":
    main()


Bar chart with honest scale

examples/bar_honest_scale.py
"""Bar chart with honest scale example for SignalPlot."""

from __future__ import annotations

import matplotlib.pyplot as plt

import signalplot as sp


def main() -> None:
    sp.apply()

    categories = ["Residential", "Commercial", "Industrial", "Other"]
    values = [120, 150, 90, 60]

    plt.figure()
    plt.bar(categories, values, color="0.6")
    plt.title("Average demand by sector")
    plt.ylim(bottom=0)

    sp.save("bar.png")
    plt.show()


if __name__ == "__main__":
    main()


Event highlight

examples/event_highlight.py
"""Event / regime highlight example for SignalPlot."""

from __future__ import annotations

import numpy as np
import matplotlib.pyplot as plt

import signalplot as sp


def main() -> None:
    sp.apply()

    rng = np.random.default_rng(4)
    dates = np.arange(0, 48)
    values = np.cumsum(rng.normal(size=dates.size))
    event_date = 24

    plt.figure()
    plt.plot(dates, values, color="black")
    plt.axvline(event_date, color="red", linewidth=1.0)
    plt.title("Demand with policy change")

    sp.save("event_line.png")
    plt.show()


if __name__ == "__main__":
    main()