Project 3

This graph shows the comparison between the Highschool and Middleschool lights. The Highschool lights on avaerage are brighter than the Middleschool lights.

Code


import matplotlib.pyplot as plt
import numpy as np
import itertools
import csv

limit = 25

x = np.arange(1, limit)
y1 = []
y2 = []
y3 = []
y4 = []
with open("data1.csv", "r") as datafile:
    data = csv.reader(datafile, delimiter=",")
    for rows in itertools.islice(data, 1, limit):
        y1.append(float(rows[1]))

with open("data4.csv", "r") as datafile:
    data = csv.reader(datafile, delimiter=",")
    for rows in itertools.islice(data, 1, limit):
        y2.append(float(rows[1]))

with open("data2.csv", "r") as datafile:
    data = csv.reader(datafile, delimiter=",")
    for rows in itertools.islice(data, 1, limit):
        y3.append(float(rows[1]))

with open("data3.csv", "r") as datafile:
    data = csv.reader(datafile, delimiter=",")
    for rows in itertools.islice(data, 1, limit):
        y4.append(float(rows[1]))

plt.plot(x, y1, color="red")
plt.plot(x, y2, color="blue")
plt.plot(x, y3, color="pink")
plt.plot(x, y4, color="green")
plt.axis([0,25,0,4])
plt.title("Comparing Lights and their Brightness")
plt.xlabel("seconds")
plt.ylabel("Brightness")
plt.legend(["MS Lights 1","HS Lights 1", "MS Lights 2", "HS Lights 2"], loc="lower left")
plt.show()