In [2]:
## import libraries
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
#allows us to show plots in notebook
%matplotlib inline
In [7]:
filename = '' #created a variable that it would be easy to call
sheef = pd.read_csv(filename, sep = '\s+', header=1, index_col='Date')
#made dataframe into variable sheef, deleted unnecessary header, changed the index
sheef
Out[7]:
In [122]:
sheef['decade'] = sheef['year'] // 10*10
# plot the magnitude of earthquakes over time
plt.bar (sheef.Depth, sheef.MW)
#plotted MW column
In [1]:
#make biger figure
plt.figure(figsize=(10,8))
#plot the depth of earthquakes over time
sheef['Depth'].plot(cmap=plt.cm.cool)
#add labels
plt.ylabel('Depth')
plt.title ('The depth of earthquakes between 1627 and 2010')
In [129]:
#make bigger figure
plt.figure(figsize=(10,8))
#plot the magnitude of earthquakes over time
sheef['MW'].plot(cmap=plt.cm.autumn)
#add labels
plt.ylabel ('Magnitude')
plt.title ('Magnitude of Earthquakes between 1627 and 2010')
Out[129]:
In [49]:
#scatter plot of the magnitude of earthquakes to see the distribution
plt.figure(figsize=(10,8))
#set two variables for date (index) and magnitude
x=[sheef.index]
y=[sheef.MW]
#plot variables
plt.scatter(x, y, s=50, cmap=plt.cm.cool)
plt.show()
I chose to visualize the Magnitude with a regular plot because it clearly displayed the range of magnitudes, and a general change over time.
I chose the scatter plot because I thought it clearly displayed the variety of data, and the individual earthquakes clearer than the general plot did.
I thought a bar graph would be a good representation of the depth of the earthquakes, but I couldn't get it to work so I guess it isn't representing it very well. I changed this to a regular plot so there was an actual visual. This shows the different depths almost as well.
I learned that there was more data collected closer to our year, and that there was more earthquakes with a higher magnitude and much greater depth than in previous years. This indicates more seismic activity in recent years.
In [ ]:
In [ ]: