You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
explore_math/ch2_graphing/temp_decimal.py

21 lines
430 B
Python

import numpy as np
import matplotlib.pyplot as plt
from decimal import Decimal
nyc_temp = [
50.9, 60.3, 54.4, 52.4, 51.5, 52.8,
56.8, 55.0, 55.3, 54.0, 56.7, 56.4, 57.3
]
# Preserve Decimal behavior
dec_nyc_temp = [Decimal(str(x)) for x in nyc_temp]
years = list(range(2000, 2013))
plt.plot(years, dec_nyc_temp, marker="o")
plt.xlabel("Year")
plt.ylabel("Temperature")
plt.title("NYC Temperature by Year")
plt.show()