""" Example: Comparing multiple weather stations Meteorological data provided by Meteostat (https://dev.meteostat.net) under the terms of the Creative Commons Attribution-NonCommercial 4.0 International Public License. The code is licensed under the MIT license. """ from datetime import datetime import matplotlib.pyplot as plt from meteostat import Daily # Time period start = datetime(2019, 1, 1) end = datetime(2019, 12, 31) # Get daily data data = Daily(['71624', '72295', '68816', '94767'], start, end) data = data.fetch() # Plot chart data.unstack('station')['tavg'].plot( legend=True, ylabel='Avg. Daily Temperature °C', title='Average Temperature Report for 2019') plt.show()
""" from meteostat import Stations, Daily from datetime import datetime import matplotlib.pyplot as plt # Get weather stations by Meteostat ID stations = Stations(id=['D1424', '10729', '10803', '10513']).fetch() # Get names of weather stations names = stations['name'].to_list() # Get daily data since 2000 data = Daily(stations, start=datetime(2000, 1, 1), end=datetime(2019, 12, 31)) # Aggregate annually data = data.aggregate(freq='1Y').fetch() # Plot data fig, ax = plt.subplots(figsize=(8, 6)) data.unstack('station')['tmax'].plot(kind='line', legend=True, ax=ax, style='.-', ylabel='Max. Annual Temperature (°C)', title='Max. Temperature Report') plt.legend(names) # Show plot plt.show()