Weather Visualization
- Weather Patterns in Seattle and Austin
- Monthly Precipitation and Temperature in Seattle and Austin
- Precipitation data in Seattle and Austin
- Adding error-bars
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
%matplotlib inline
austin_weather = pd.read_csv('../data/austin_weather.csv')
seattle_weather = pd.read_csv('../data/seattle_weather.csv')
austin_weather.head()
seattle_weather.head()
plt.style.use('ggplot')
fig, ax = plt.subplots(figsize=(14,6))
# Plot MLY-PRCP-NORMAL from seattle_weather against the MONTH
ax.plot(seattle_weather["MONTH"], seattle_weather['MLY-PRCP-NORMAL'], c='blue', marker='o', linestyle='dashdot')
# Plot MLY-PRCP-NORMAL from austin_weather against MONTH
ax.plot(austin_weather['MONTH'], austin_weather['MLY-PRCP-NORMAL'], c='red', marker='v', linestyle='--')
ax.set_xlabel('Time (months)')
ax.set_ylabel('Precipitation (inches)')
ax.set_title('Weather patterns in Seattle and Austin')
plt.show()
fig,ax=plt.subplots(2,2, sharey=True, figsize=(15,4))
ax[0,0].plot(seattle_weather['MONTH'], seattle_weather['MLY-PRCP-NORMAL'])
ax[0,1].plot(seattle_weather['MONTH'], seattle_weather['MLY-TAVG-NORMAL'])
ax[1,0].plot(austin_weather['MONTH'], austin_weather['MLY-PRCP-NORMAL'])
ax[1,1].plot(austin_weather['MONTH'], austin_weather['MLY-TAVG-NORMAL'])
plt.show()
# Create a figure and an array of axes: 2 rows, 1 column with shared y axis
fig, ax = plt.subplots(2, 1, sharey=True)
# Plot Seattle precipitation data in the top axes
ax[0].plot(seattle_weather['MONTH'], seattle_weather['MLY-PRCP-NORMAL'], color = 'b')
ax[0].plot(seattle_weather['MONTH'], seattle_weather['MLY-PRCP-25PCTL'], color = 'b', linestyle = '--')
ax[0].plot(seattle_weather['MONTH'], seattle_weather['MLY-PRCP-75PCTL'], color = 'b', linestyle = '--')
# Plot Austin precipitation data in the bottom axes
ax[1].plot(austin_weather['MONTH'], austin_weather['MLY-PRCP-NORMAL'], color = 'r')
ax[1].plot(austin_weather['MONTH'], austin_weather['MLY-PRCP-25PCTL'], color = 'r', linestyle = '--')
ax[1].plot(austin_weather['MONTH'], austin_weather['MLY-PRCP-75PCTL'], color = 'r', linestyle = '--')
plt.show()
plt.style.use('seaborn')
fig, ax = plt.subplots(figsize=(14,6))
ax.errorbar(seattle_weather['MONTH'], seattle_weather['MLY-TAVG-NORMAL'],yerr=seattle_weather['MLY-TAVG-STDDEV'])
ax.errorbar(austin_weather['MONTH'], austin_weather['MLY-TAVG-NORMAL'],yerr=austin_weather['MLY-TAVG-STDDEV'])
ax.set_ylabel('Temperature (Fahrenheit)')
plt.show()