-
import csvfrom matplotlib import pyplot as pltfrom datetime import Datetimefilename = ' sitka_weather_07-2014.csv ' with open (fileName) as F:reader = Csv.reader (f) header_row = Next (rea Der) # Print (header_row) # for index, Column_header in Enumerate (header_row): # When you need both index and value values, you can use enumerate # # Print (index, column_header) dates,hights = [], [] for row in reader:current_date = Datetime.strpt IME (row[0], '%y-%m-%d ') dates.append (current_date) hights.append (int (row[1))) print (hights) FIG = plt. Figure (dpi=128, figsize= (6)) Plt.plot (dates, hights, c= ' Red ') # Sets the format of the graphic Plt.title ("Dialy High Temperatures,ju Ly ", fontsize=24) Plt.xlabel (", fontsize=16) Fig.autofmt_xdate () Plt.ylabel ("Temperature (F)", fontsize=16) Plt.tick_params (axis= ' both ', which= ' major ', labelsize=16) plt.savefig ("Temperature.png", bbox_inches= ' tight ') pl T.show ()
Run result
- Temperature.png
Python read the CSV format document and use Matplotlib to draw the chart