A shared Matplotlib theme for Woodwell Climate Research Center
If you would like to use the theme in your pip or conda environment, you can install it with:
pip install git+https://github.com/woodwellrisk/theme-py.git
Later on, you should be able to pull package changes with:
pip install --upgrade git+https://github.com/woodwellrisk/theme-py.git
In a Python script or Jupyter Notebook, you can import the theme with:
import woodwell_theme as themeThen, to load the theme and apply the provided defaults to every figure, you can run:
theme.load()You can view which fonts or colors are available simply by printing them out.
print(theme.colors)
print(theme.datasets)
print(theme.fonts)
print(theme.units)Alternatively, you can import these classes directly with:
from woodwell_theme import colors, datasets, fonts, units
print(colors)
...If you want more in-depth information on how to use the theme or longer examples with code that can by copied and pasted into your project, you can view our technical documentation built with Jupyter Book and MyST.
To view the documentation, you first need to clone this repository and then install the needed Python dependencies.
git clone https://github.com/WoodwellRisk/theme-py.git .
cd theme-py
mamba env create -f environment.yml
mamba activate woodwell_theme
From there, you can navigate to the docs/ folder and run:
jupyter book build
jupyter book start --execute
If everything is working, you should see a message like this:
✨✨✨ Starting Book Theme ✨✨✨
🔌 Server started on port 3000! 🥳 🎉
👉 http://localhost:3000 👈
Now, you can paste http://localhost:3000/ into your web browser and start viewing with the docs.
The current suite of tests get run automatically each time changes are pushed to the main branch.
We use pre-commit to make sure that all code is formatted and linted before changes are committed to the main branch of this repository. In order to push local changes or open a pull request, you would need to first clone this repository and install the necessary Python dependencies, exactly how it is described in the Documentation section.
Next, you need to install and run the pre-commit hooks that we have installed.
pre-commit install
pre-commit run --all-files
Note: you will not be able to push changes until you fix all errors raised by pre-commit. This does not make sure that the code itself is accurate or does what it is meant to do, but instead ensures that all code uses Python style guideline best practices, deletes unused code, and is syntax error free.
A second round of testing is needed to make sure that intended changes do not break the functionality of the theme. After making changes to the woodwell_theme package code, you will need to run and pass all of the the pytest tests.
pytest -vv