Question
Hi, I am working on a project in Python. It is supposed to read temperatures in a csv file and convert the temperatures from Celsius
Hi, I am working on a project in Python. It is supposed to read temperatures in a csv file and convert the temperatures from Celsius to Fahrenheit and make a graph. Whenever I run my program, the graphing area is blank and does not use the x or y tickmarks that I specify. This is what I have so far:
import csv import numpy as np import matplotlib.pyplot as plt
def main(): temp_file = open('data.csv', "r") for line in temp_file: Oslo =[] Harrisburg =[] Honolulu =[] Santiago =[] new_array=[] for year in range(2000,2018): for month in range(1,12): Oslo.append(0) Harrisburg.append(0) Honolulu.append(0) Santiago.append(0) new_array.append(year) plt.plot(new_array, Oslo, 'b-', label = "Oslo") plt.plot(new_array, Harrisburg, 'r-', label = "Harrisburg") plt.plot(new_array, Honolulu, 'g-', label = "Honolulu") plt.plot(new_array, Santiago, 'y-', label = "Santiago")
plt.legend(shadow = True, loc = "best") plt.xticks(np.arange([0, 216, 1.0)])) plt.yticks(np.arange([-10, 30, 10.0])) plt.xlabel('Year') plt.ylabel('Temperature') plt.title("Average Monthly Temperature in Four Cities")
plt.show() main()
Any insight would be greatly appreciated. Thank you.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started