Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
38 lines (30 sloc) 1.31 KB
# import packages
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
from scipy.ndimage.filters import gaussian_filter1d
# read in csv
df = pd.read_csv('/Users/user/Desktop/CNTRY_AVG/TA/ERA5_TA-_0002m_ADMIN-0_Glob_025d_01y_1979_2018.csv',
# Create lists for countries, database columns, smoothing
w_africa = ('SEN','GMB','GNB','GIN','SLE','LBR')
w_df = (df.SEN, df.GMB, df.GNB, df.GIN, df.SLE, df.LBR)
colors = ('#FF0000','#FF3300','#FF6600','#FF9900','#FFCC00','#FFFF00')
# wrap plotting inside style context for nice looking plot theme
# smooth plots with gaussian filter, set sigma for amount of smoothing
for (w, wd, c) in zip(w_africa, w_df, colors):
s = gaussian_filter1d(wd, sigma=5)
plt.plot(df.index, s ,linestyle='--',color=c)
# setup plot with labels and title
fig = plt.gcf()
fig.set_size_inches(18.5, 10.5)
plt.xlabel('Year', fontsize=14)
plt.ylabel('Celcius', fontsize=14)
fig.suptitle('Area averaged ERA5 temperature data, for selected countries in W.Africa.', fontsize=16)
# add the unsmoothed line plots per country for reference
for wd, c in zip(w_df, colors):
wd.plot(color = c)
# display plot
You can’t perform that action at this time.