Skip to content

Instantly share code, notes, and snippets.

@ifindev
Last active April 30, 2020 14:42
Show Gist options
  • Save ifindev/f501ffa84b73ffa22b2be18237e08ef5 to your computer and use it in GitHub Desktop.
Save ifindev/f501ffa84b73ffa22b2be18237e08ef5 to your computer and use it in GitHub Desktop.
Program sederhana untuk membuat grafik eksponensial peningkatan konsentrasi CO2
"""
Author : Muhammad Arifin
Date : 30 April 2020
Deskripsi: Program sederhana untuk membuat grafik eskponensial
peningkatan konsentrasi CO2 seiring berjalannya waktu.
"""
import numpy as np
import matplotlib.pyplot as plt
# Buat fungsi matematis eksponensial
# peningkatan konsentrasi CO2 seiring berjalannya waktu.
t = np.arange(-1000, 10001, 50)
fan2 = (390 - 7219) * np.exp(-0.00042*t) + 7219
fan8 = (390 - 5293) * np.exp(-0.00061*t) + 5293
# Dummy data: Function with gaussian noise
mu, sigma = 0, 50
s = np.random.normal(mu, sigma, len(t))
fan2_data = fan2 + s
fan8_data = fan8 + s
# Buat grafik dari fungsi eksponensial fan2 dan fan8
plt.figure("Fan Graphic")
plt.title("$CO_{2}$ Concentration Over Time")
plt.plot(t, fan2_data, "o", label = "Fan 2", color = 'limegreen', markersize = 3)
plt.plot(t, fan2, label = "Fitted line-fan 2", color = 'red', linewidth = 2)
plt.plot(t, fan8_data, "o", label = "Fan 8", color = 'darkred', markersize = 3)
plt.plot(t, fan8, label = "Fitted line-fan 8", color = 'blue', linewidth = 2)
plt.xlim([0,7000])
plt.ylim([0,7000])
plt.xticks(np.arange(0, 7001, 1000))
plt.yticks(np.arange(0, 7001, 1000))
plt.xlabel("Time (s)")
plt.ylabel("$CO_{2}$ (ppm)")
plt.legend()
plt.grid()
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment