''' Middeltemperaturer pr mnd i Skien 2005-2015 https://www.timeanddate.no/vaer/norge/skien/klima ''' #%% Import av pakker import numpy as np import matplotlib.pyplot as plt # %% Definisjon av variabler med tallverdier mnd = np.array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) # [mnd nr] temp = np.array([-3, -2, 2, 7, 11, 15, 17, 16, 12, 6, 2, -3]) # [grad C] #%% Beregning av middelverdi: mean_temp = np.mean(temp) print(f'Middelverdi = {mean_temp:.1f}') #%% Plotting av temperaturene plt.close('all') plt.figure(1) plt.plot(mnd, temp, 'bo-', label='temperatur') plt.plot(mnd, temp*0 + mean_temp, 'g', label='middelverdi') plt.legend() plt.title('Midlere maanedstemperatur i Skien 2005-2015') plt.xlabel('Maaned nr.') plt.ylabel('Grader C') plt.xlim(0, 13) plt.ylim(-5, 20) plt.grid() plt.show()