Last active
December 1, 2021 13:15
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is very interested ,how to plot a time series temp ?