Skip to main content

Provides support for a cftime axis in matplotlib

Project description

nc-time-axis

Support for a cftime axis in matplotlib

cirrus-ci codecov pre-commit.ci conda-forge pypi black license contributors

Installation

Install nc-time-axis either with conda:

    conda install -c conda-forge nc-time-axis

Or pip:

    pip install nc-time-axis

Example

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()

alt text

Reference

  • cftime - Time-handling functionality from netcdf4-python.
  • matplotlib - Plotting with Python.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for nc-time-axis, version 1.3.1
Filename, size File type Python version Upload date Hashes
Filename, size nc_time_axis-1.3.1-py3-none-any.whl (12.5 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size nc-time-axis-1.3.1.tar.gz (60.1 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page