Implementation of GGPLOTS using Quakes Dataset

library(ggplot2)
ggplot(quakes, aes(x = long, y = lat, color = depth, size = mag)) +
  geom_point(alpha = 0.7) +
  scale_color_gradient(low = "blue", high = "red") +
  labs(title = "Earthquake Locations in New Zealand",
       x = "Longitude",
       y = "Latitude",
       color = "Depth",
       size = "Magnitude")

The earthquakes with the highest magnitudes are also the earthquakes that occur at the greatest depths. This suggests that there may be a link between earthquake magnitude and depth. The earthquakes with the highest magnitudes are also the earthquakes that occur along the boundaries of tectonic plates. This suggests that there may be a link between earthquake magnitude and plate boundaries.

ggplot(quakes, aes(x = depth)) +
  geom_histogram(binwidth = 5, fill = "#7D0112", color = "white", alpha = 0.7) +
  labs(title = "Distribution of Earthquake Depths",
       x = "Depth",
       y = "Frequency")

The earthquakes with the deepest depths are also the earthquakes that occur in the subduction zones. Subduction zones are areas where one tectonic plate is sliding underneath another. The earthquakes with the deepest depths are also the earthquakes that occur along the mid-ocean ridges. Mid-ocean ridges are areas where new oceanic crust is being created. The variation in earthquake depth between earthquakes is greater than the variation in earthquake magnitude or plate boundary location. This suggests that there may be other factors that are contributing to earthquake depth, such as the type of fault rupture or the amount of energy released.

quakes$depth_cat <- cut(quakes$depth, breaks = c(0, 30, 60, 90, max(quakes$depth)), labels = c("Shallow", "Moderate", "Deep", "Very Deep"))
ggplot(quakes, aes(x = depth_cat, y = mag)) +
  geom_boxplot(fill = "#0084A7", alpha = 0.7) +
  labs(title = "Magnitude Distribution by Depth Category",
       x = "Depth Category",
       y = "Magnitude")

The graph shows that the median magnitude for earthquakes in the 0-10 km depth category is 2.5. The middle 50% of earthquakes in this depth category have magnitudes between 2 and 3. The outliers are earthquakes with magnitudes greater than 4.5.

ggplot(quakes, aes(x = depth)) +
  geom_density(fill = "#71B3A5", color = "white") +
  labs(title = "Density Plot of Earthquakes' Depth",
       x = "Depth", y = "Density")

The graph also shows that there is a bimodal distribution of earthquake depths, with a secondary peak at depths of around 400 kilometers. This secondary peak is due to deep focus earthquakes, which are earthquakes that occur at depths of more than 70 kilometers.

ggplot(quakes, aes(x = lat, y = mag)) +
  geom_point(alpha = 0.7, color = "#67223F") +
  labs(title = "Scatter Plot of Earthquake Magnitude vs. Latitude",
       x = "Latitude", y = "Magnitude") +
  theme_minimal()

Earthquakes with larger magnitudes tend to occur at deeper depths. There is a large variation in magnitude for earthquakes at all depths. The magnitude of an earthquake depends on a number of factors, including the size of the fault rupture, the amount of energy released, and the distance from the epicenter.