| 
 | 1 | +# nc-time-axis  | 
 | 2 | + | 
 | 3 | +<h4 align="center">  | 
 | 4 | +    Support for a cftime axis in matplotlib  | 
 | 5 | +</h4>  | 
 | 6 | + | 
 | 7 | +<p align="center">  | 
 | 8 | + | 
 | 9 | +<a href="https://cirrus-ci.com/github/SciTools-/nc-time-axis">  | 
 | 10 | +  <img src="https://api.cirrus-ci.com/github/SciTools/nc-time-axis.svg?branch=master"  | 
 | 11 | +       alt="cirrus-ci">  | 
 | 12 | +</a>  | 
 | 13 | +<a href="https://codecov.io/gh/SciTools/nc-time-axis">  | 
 | 14 | +  <img src="https://codecov.io/gh/SciTools/nc-time-axis/branch/master/graph/badge.svg?token=JicwCCHwLd"  | 
 | 15 | +       alt="codecov">  | 
 | 16 | +</a>  | 
 | 17 | +<a href="https://results.pre-commit.ci/latest/github/SciTools/nc-time-axis/master">  | 
 | 18 | +  <img src="https://results.pre-commit.ci/badge/github/SciTools/nc-time-axis/master.svg"  | 
 | 19 | +       alt="pre-commit.ci">  | 
 | 20 | +</a>  | 
 | 21 | +<a href="https://anaconda.org/conda-forge/nc-time-axis">  | 
 | 22 | +  <img src="https://img.shields.io/conda/vn/conda-forge/nc-time-axis?color=orange&label=conda-forge&logo=conda-forge&logoColor=white"  | 
 | 23 | +       alt="conda-forge">  | 
 | 24 | +</a>  | 
 | 25 | +<a href="https://pypi.org/project/nc-time-axis/">  | 
 | 26 | +  <img src="https://img.shields.io/pypi/v/nc-time-axis?color=orange&label=pypi&logo=python&logoColor=white"  | 
 | 27 | +       alt="pypi">  | 
 | 28 | +</a>  | 
 | 29 | +<a href="https://github.com/psf/black">  | 
 | 30 | +  <img src="https://img.shields.io/badge/code%20style-black-000000.svg"  | 
 | 31 | +       alt="black">  | 
 | 32 | +</a>  | 
 | 33 | +<a href="https://github.com/SciTools/nc-time-axis/blob/master/LICENSE">  | 
 | 34 | +  <img src="https://img.shields.io/github/license/SciTools/nc-time-axis?style=plastic"  | 
 | 35 | +       alt="license">  | 
 | 36 | +</a>  | 
 | 37 | +<a href="https://github.com/SciTools/nc-time-axis/graphs/contributors">  | 
 | 38 | +  <img src="https://img.shields.io/github/contributors/SciTools/nc-time-axis?style=plastic"  | 
 | 39 | +       alt="contributors">  | 
 | 40 | +</a>  | 
 | 41 | +</p>  | 
 | 42 | + | 
 | 43 | + | 
 | 44 | +## Installation  | 
 | 45 | +Install `nc-time-axis` either with `conda`:  | 
 | 46 | +```shell  | 
 | 47 | +    conda install -c conda-forge nc-time-axis  | 
 | 48 | +```  | 
 | 49 | +Or `pip`:  | 
 | 50 | +```shell  | 
 | 51 | +    pip install nc-time-axis  | 
 | 52 | +```  | 
 | 53 | + | 
 | 54 | + | 
 | 55 | +## Example  | 
 | 56 | + | 
 | 57 | +    import random  | 
 | 58 | + | 
 | 59 | +    import cftime  | 
 | 60 | +    import matplotlib.pyplot as plt  | 
 | 61 | + | 
 | 62 | +    from nc_time_axis import CalendarDateTime  | 
 | 63 | + | 
 | 64 | +    calendar = "360_day"  | 
 | 65 | +    dt = [  | 
 | 66 | +        cftime.datetime(year=2017, month=2, day=day, calendar=calendar)  | 
 | 67 | +        for day in range(1, 31)  | 
 | 68 | +    ]  | 
 | 69 | +    cdt = [CalendarDateTime(item, calendar) for item in dt]  | 
 | 70 | +    temperatures = [round(random.uniform(0, 12), 3) for _ in range(len(cdt))]  | 
 | 71 | + | 
 | 72 | +    plt.plot(cdt, temperatures)  | 
 | 73 | +    plt.margins(0.1)  | 
 | 74 | +    plt.ylim(0, 12)  | 
 | 75 | +    plt.xlabel("Date")  | 
 | 76 | +    plt.ylabel("Temperature")  | 
 | 77 | +    plt.show()  | 
 | 78 | + | 
 | 79 | +  | 
 | 80 | + | 
 | 81 | + | 
 | 82 | +## Reference  | 
 | 83 | +* [cftime](https://github.com/Unidata/cftime) - Time-handling functionality from netcdf4-python.  | 
 | 84 | +* [matplotlib](http://matplotlib.org/) - Plotting with Python.  | 
0 commit comments