#! /usr/bin/env python3
# -*- coding:utf8 -*-
import matplotlib.pyplot as plt
import matplotlib.dates
import numpy as np
import datetime
from math import *
plt.rcParams['font.sans-serif'] = 'DejaVu Sans'
# data_source: energy-charts.info
prices2011_weekly = np.array([
48.00, 45.62, 49.44, 55.55, 51.92, 44.59, 51.87, 55.39, 56.35, 52.01,
55.17, 53.55, 55.02, 53.41, 51.85, 55.08, 46.58, 52.91, 59.29, 58.90,
56.57, 53.82, 56.81, 56.30, 45.02, 49.77, 48.87, 49.73, 46.14, 41.65,
46.60, 40.74, 49.03, 54.53, 52.58, 50.24, 50.15, 54.45, 54.20, 49.12,
52.09, 53.12, 52.90, 52.03, 53.74, 58.05, 58.73, 51.18, 45.24, 46.73,
44.25, 33.05, 30.71, 40.10, 44.92, 40.82, 51.03, 72.96, 54.70, 42.10,
46.22, 43.83, 43.47, 42.39, 35.86, 39.75, 42.95, 47.36, 44.94, 38.19,
41.09, 38.16, 38.85, 35.76, 39.04, 39.67, 39.22, 37.68, 42.66, 40.58,
38.60, 43.17, 40.69, 41.99, 43.61, 48.91, 45.58, 46.20, 47.41, 46.60,
42.30, 39.82, 44.18, 40.16, 47.46, 41.41, 39.56, 48.19, 48.08, 46.37,
49.63, 55.05, 44.78, 2.75, 22.50, 46.06, 50.09, 49.56, 33.65, 39.45,
45.21, 46.97, 49.13, 42.55, 40.91, 37.70, 34.55, 40.99, 50.33, 32.13,
31.77, 29.22, 30.35, 29.31, 33.76, 36.81, 30.89, 27.39, 26.39, 28.18,
32.82, 31.42, 37.19, 41.64, 35.53, 37.04, 31.92, 41.71, 43.06, 40.09,
44.22, 40.74, 45.12, 35.04, 46.26, 39.79, 35.40, 28.26, 31.11, 39.72,
45.86, 41.96, 40.98, 50.42, 38.35, 18.08, 25.67, 27.50, 38.08, 43.64,
39.22, 35.62, 32.48, 32.15, 34.11, 37.65, 31.89, 21.16, 33.78, 33.96,
32.81, 27.14, 29.50, 32.43, 29.78, 27.34, 35.19, 32.57, 32.18, 30.79,
29.04, 32.97, 32.57, 30.53, 32.44, 31.35, 32.34, 28.64, 26.42, 23.63,
33.07, 31.10, 35.28, 34.60, 34.75, 38.70, 33.28, 38.44, 29.87, 36.29,
32.72, 35.53, 40.91, 37.86, 45.27, 36.83, 34.86, 13.74, nan, nan,
21.07, 39.89, 31.59, 39.80, 35.22, 36.10, 35.80, 28.13, 34.12, 33.05,
37.16, 21.26, 33.70, 24.99, 30.97, 30.28, 26.35, 22.25, 27.40, 27.69,
25.26, 29.97, 30.14, 31.41, 33.54, 34.11, 39.30, 41.80, 23.61, 29.39,
32.95, 35.63, 28.92, 34.57, 27.40, 30.91, 33.35, 34.50, 38.41, 37.82,
41.94, 40.16, 38.80, 30.11, 27.24, 38.59, 29.84, 29.61, 34.26, 19.37,
22.63, 26.75, 30.10, 39.58, 25.10, 19.88, 19.24, 25.19, 20.98, 23.87,
26.07, 26.20, 25.15, 19.57, 23.91, 25.06, 22.64, 24.74, 24.02, 18.26,
23.41, 24.73, 25.53, 27.31, 28.18, 27.49, 26.93, 23.92, 25.02, 29.00,
31.11, 29.13, 24.92, 27.10, 26.80, 28.84, 31.13, 30.01, 31.45, 29.28,
31.90, 36.75, 38.44, 41.07, 38.32, 44.92, 36.70, 33.15, 36.52, 41.48,
45.92, 45.55, 18.40, 39.59, 43.04, 62.11, 63.67, 49.34, 52.36, 41.11,
30.10, 29.04, 34.75, 31.18, 28.23, 31.72, 33.31, 30.12, 27.48, 29.50,
19.10, 34.58, 32.85, 29.74, 32.36, 25.50, 28.27, 33.26, 31.17, 33.70,
35.60, 35.29, 33.28, 25.45, 30.79, 29.20, 28.71, 36.34, 32.98, 25.43,
38.90, 39.17, 25.87, 30.16, 39.36, 34.08, 17.31, 45.38, 42.61, 30.75,
46.51, 34.20, 30.60, 47.55, 12.83, 13.50, 36.01, 30.81, 35.42, 27.69,
43.42, 33.97, 45.01, 37.48, 41.11, 34.92, 35.32, 40.26, 30.79, 31.29,
39.58, 30.32, 25.54, 30.64, 34.64, 31.89, 42.39, 45.68, 45.89, 35.92,
41.25, 45.77, 46.27, 50.66, 53.57, 54.57, 54.94, 52.34, 59.16, 56.93,
62.40, 60.20, 53.30, 46.34, 48.03, 60.16, 58.19, 50.68, 45.50, 56.21,
53.42, 57.85, 60.73, 46.78, 45.94, 56.15, 44.99, 37.65, 48.78, 40.56,
67.03, 51.96, 47.16, 36.73, 43.16, 42.82, 26.52, 25.05, 31.18, 37.19,
37.53, 42.21, 39.52, 26.32, 36.83, 42.08, 37.18, 40.52, 32.86, 33.75,
26.28, 37.44, 35.00, 31.26, 37.21, 41.70, 43.01, 42.15, 39.08, 30.10,
34.85, 41.69, 33.74, 38.04, 37.65, 40.30, 32.12, 33.93, 34.56, 39.46,
36.37, 39.70, 42.29, 44.21, 38.97, 43.14, 27.45, 31.01, 28.40, 31.77,
34.24, 30.72, 42.88, 32.91, 27.17, 20.33, 19.34, 22.70, 27.56, 22.59,
24.84, 16.32, 19.10, 19.54, 15.76, 9.91, 19.42, 20.65, 20.62, 19.97,
13.79, 18.18, 24.26, 28.98, 30.19, 27.91, 23.86, 35.44, 31.81, 26.89,
32.72, 35.60, 35.84, 32.68, 43.17, 40.20, 45.24, 44.92, 41.90, 28.49,
39.93, 37.18, 29.87, 32.33, 41.82, 31.01, 44.95, 51.65, 55.00, 45.62,
34.62, 33.37, 56.40, 55.98, 45.58, 55.14, 50.96, 53.94, 49.24, 42.08,
50.00, 44.53, 44.75, 53.53, 41.11, 35.63, 61.00, 63.32, 57.45, 51.58,
55.39, 60.31, 45.90, 61.50, 72.90, 65.47, 81.28, 86.25, 91.45, 86.83,
79.38, 71.47, 75.67, 75.57, 74.94, 90.07, 103.54, 122.24, 143.33, 121.91,
128.36, 165.00, 155.94, 118.71, 143.00, 138.62, 141.01, 177.73, 205.24, 175.67,
220.18, 280.33, 292.97, 122.77, 118.44, 203.09, 166.20, 206.10, 137.00, 129.64,
112.50, 97.00, 261.90, 341.25, 217.28, 191.59, 214.08, 130.61, 169.84, 166.28,
192.47, 217.88, 181.22, 194.91, 129.64, 175.00, 163.14, 183.37, 257.00, 292.38,
263.81, 294.92, 328.22, 364.18, 382.91, 333.70, 465.71, 560.27, 558.07, 366.28,
372.82, 274.27, 327.07, 146.27, 216.74, 151.20, 110.16, 111.72, 106.28, 151.42,
220.00, 310.91, 343.07, 401.71, 204.23])
t0 = datetime.datetime(year=2011, month=1, day=5)
dates = [t0 + datetime.timedelta(days=i*7) for i in range(len(prices2011_weekly))]
fig = plt.figure(figsize=(520 / 90.0, 340 / 90.0), dpi=72)
plt.plot(dates, 0.1 * prices2011_weekly)
plt.xlim(datetime.datetime(year=2011, month=1, day=1), datetime.datetime(year=2023, month=1, day=1))
plt.ylim(0)
plt.gca().xaxis.set_major_locator(matplotlib.dates.YearLocator(2))
plt.gca().xaxis.set_minor_locator(matplotlib.dates.YearLocator(1))
plt.gca().xaxis.set_major_formatter(matplotlib.dates.DateFormatter('%Y'))
plt.grid(True, which='both')
plt.xlabel('t')
plt.ylabel('price [ct / kWh]')
plt.tight_layout()
plt.savefig('Electricity-spot-market-germany-2011-2022.svg')