Skip to content

Instantly share code, notes, and snippets.

@clampr
Last active December 1, 2021 13:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clampr/e89e20952275a8abd193f9f853200db4 to your computer and use it in GitHub Desktop.
Save clampr/e89e20952275a8abd193f9f853200db4 to your computer and use it in GitHub Desktop.
Example that shows how to plot temperature data for Vancouver, BC from 2018 using Meteostat Python library.
# Import Meteostat library and dependencies
from datetime import datetime
import matplotlib.pyplot as plt
from meteostat import Stations, Daily
# Set coordinates of Vancouver
lat = 49.2497
lon = -123.1193
# Set time period
start = datetime(2018, 1, 1)
end = datetime(2018, 12, 31)
# Get closest weather station to Vancouver, BC
stations = Stations()
stations = stations.nearby(lat, lon)
stations = stations.inventory('daily', (start, end))
station = stations.fetch(1)
# Get daily data for 2018 at the selected weather station
data = Daily(station, start, end)
data = data.fetch()
# Plot line chart including average, minimum and maximum temperature
data.plot(y=['tavg', 'tmin', 'tmax'])
plt.show()
@Rwakageyo
Copy link

This is very interested ,how to plot a time series temp ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment