Skip to content

Instantly share code, notes, and snippets.

@alanjones2
Created February 20, 2022 21:12
Show Gist options
  • Save alanjones2/ac348b5b1e672715b822a2b99685e891 to your computer and use it in GitHub Desktop.
Save alanjones2/ac348b5b1e672715b822a2b99685e891 to your computer and use it in GitHub Desktop.
mercury weather 2
import numpy as np
import pandas as pd
weather=pd.read_csv('heathrowDataFiltered.csv')
import matplotlib.pyplot as plt
fig, axes = plt.subplots(nrows=2, ncols=2,figsize=(10,7))
def plotchart(y,yticks,label,ax, kind):
xticks= [1,2,3,4,5,6,7,8,9,10,11,12]
xlabels = ['Jan','Feb','Mar','Apr','May',
'Jun','Jul','Aug','Sep','Oct','Nov','Dec']
ax=weather[weather['Year']==year].plot(kind=kind,y = y, x ='Month',
yticks = yticks, xticks = xticks,
legend = False, title = y, ax=ax)
ax.set_xticklabels(xlabels)
ax.set_ylabel(label)
yticks = [0,5,10,15,20,25,30]
label="Degrees Celsius"
plotchart('Tmax', yticks, label, axes[0,0], 'line')
plotchart('Tmin', yticks, label, axes[0,1], 'line')
yticks = [0,10,20,30,40,50,60,70,80,90,100]
label="Millimetres"
plotchart('Rain', yticks, label, axes[1,0], 'bar')
yticks = [0,50,100,150,200,250,300]
label="Hours"
plotchart('Sun', yticks, label, axes[1,1], 'bar')
print(f"Year: {year}")
plt.tight_layout()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment