Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Importing Modules
- import numpy as np
- import matplotlib.pyplot as plt
- #The file 'nh_temperature.txt' is a compilation of Monthly Temperature Anomalies for the Northern Hemisphere that covers #1850 - 2015. First column is the years and next columns are the Months (Jan, Feb, Mar, Apr,..etc)
- #Reading the txt file
- data = np.genfromtxt('nh_temperature.txt') #Here you read ALL the data from the TXT
- data #This prints the data that you just read
- #Extracting the years column
- years = data[:,0] # [row, column] -> this means we are extracting all ROWS from column 0
- years
- #Extracting January
- jan = data[:,1] #All rows from column 1
- #Plotting the data of January as a time series
- plt.figure(figsize =(12,7)) #Size of the figure
- plt.plot(years, jan) #plt.plot(x,y)
- plt.xlabel('Years')
- plt.ylabel('Temperature Anomaly')
- plt.title('Temperature Anomalies for NH of January 1850-2015')
- #Now try to extract and plot all the other months one by one
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement