solution_063b.py

#!/usr/bin/python3
# ===================================================================
# plot forecast high/low temperatures
# ===================================================================

import numpy as np
import matplotlib.pyplot as plt

# ---- combined data

forecast = [ [    'Friday', 'Fri', None, 62],
             [  'Saturday', 'Sat',   89, 63],
             [    'Sunday', 'Sun',   90, 62],
             [    'Monday', 'Mon',   89, 61],
             [   'Tuesday', 'Tue',   86, 60],
             [ 'Wednesday', 'Wed',   87, 62],
             [  'Thursday', 'Tru',   89, 65],
             [    'Friday', 'Fri',   92, None] ]

# ---- plot

x_high = []
y_high = []
x_low  = []
y_low  = []
s_day  = []                    # short day
x_ticks= []

for idx in range(len(forecast)):

    hi = forecast[idx][2]
    if hi is not None:
        x_high.append(idx)
        y_high.append(hi)

    lo = forecast[idx][3]
    if lo is not None:
        x_low.append(idx)
        y_low.append(lo)

    x_ticks.append(idx)

    s_day.append(forecast[idx][1])

plt.axis([0,len(forecast)-1,50,120])
plt.title('7 Day Forecast')
plt.ylabel('Temp F')
plt.xlabel('Day')
plt.xticks(ticks=x_ticks, labels=s_day)

#plt.plot(x_high, y_high)
#plt.plot( x_low, y_low)
plt.plot(x_high,  y_high, 'bo')
plt.plot( x_low,  y_low,  'r+')

plt.show()