This project is currently my lovejoy, I am working on getting a bit of code and AI working. Its mainly also an excuse to do some AI pratice for my algebra engine
It has been a month and the project has changed drastically over the past month, the project now follows as this:
I came up with a quick, and very dirty, script to plot datasets:
# -*- coding: utf-8 -*-
"""
Created on Fri Nov 22 11:16:20 2019
@author: james
"""
import numpy as np
import matplotlib.pyplot as plt
import pylab
def Fig(src, name):
"""
A function that plots data from a csv and outputs a graph
Input: src: A CSV file that is in the working directory
name: The name of the output file
Output: The figure, also saved to your working directory
"""
data = np.genfromtxt(src, delimiter=',', dtype=None, skip_header=1, names=('year', 'month', 'tmax', 'tmin', 'AirFrost'))
plt.title('Averaged Minimum Temperature per year from 1978 to 2019')
plt.xlabel('Month')
plt.ylabel('degrees')
plt.bar(data['month'], data['tmin'], color='c')
plt.savefig(name + ".png")
x = data['month']
y = data['tmin']
# calc the trendline
z = np.polyfit(x, y, 1)
p = np.poly1d(z)
pylab.plot(x,p(x),"r--")
# the line equation:
print("y=%.6fx+(%.6f)"%(z[0],z[1]))
Fig('CBNdata.csv', 'tmin')