graph

 avatar
unknown
c_cpp
a year ago
652 B
1
Indexable
import matplotlib.pyplot as plt
import numpy as np

# Given data
years_since_1985 = np.array([0, 5, 10, 15, 20, 25, 30])
fossil_fuel_production = np.array([85, 83, 81, 80, 79, 78, 80])

# Linear regression model
x_values = np.linspace(0, 30, 100)
y_values = -0.19 * x_values + 83.75

# Scatter plot of the data
plt.scatter(years_since_1985, fossil_fuel_production, label='Data')

# Graph of the model
plt.plot(x_values, y_values, color='red', label='Linear Regression Model')

plt.xlabel('Years since 1985')
plt.ylabel('Fossil Fuel Production (%)')
plt.title('U.S. Fossil Fuel Production')
plt.legend()
plt.grid(True)
plt.show()
Leave a Comment