Install nc-time-axis
either with conda
:
conda install -c conda-forge nc-time-axis
Or pip
:
pip install nc-time-axis
import random
import cftime
import matplotlib.pyplot as plt
from nc_time_axis import CalendarDateTime
calendar = "360_day"
dt = [
cftime.datetime(year=2017, month=2, day=day, calendar=calendar)
for day in range(1, 31)
]
cdt = [CalendarDateTime(item, calendar) for item in dt]
temperatures = [round(random.uniform(0, 12), 3) for _ in range(len(cdt))]
plt.plot(cdt, temperatures)
plt.margins(0.1)
plt.ylim(0, 12)
plt.xlabel("Date")
plt.ylabel("Temperature")
plt.show()
- cftime - Time-handling functionality from netcdf4-python.
- matplotlib - Plotting with Python.