A Python package that adds a UNDP-branded template for theming Plotly figures in line with the UNDP Design System and UNDP data viz library.
Currently, the package is distributed via GitHub only. You can install it with pip
:
pip install git+https://github.com/undp-data/[email protected]
You can also add it to your requirements.txt
:
plotly-undp-theme @ git+https://github.com/undp-data/[email protected]
See VCS Support for more details.
When you import the package, it will automatically register undp
template with plotly
. You can then use the template to style a specific figure or set it as the default to style all figures.
import plotly.express as px
import plotly.io as pio
import plotly_undp_theme # registers `undp` template
df = px.data.iris()
# use the template to style a single figure
fig = px.scatter(df, x="sepal_width", y="sepal_length", color="species", template="undp")
fig.show()
# or set it as the default to style all figures
pio.templates.default = "undp"
fig = px.scatter(df, x="sepal_width", y="sepal_length", color="species")
fig.show()
See this example notebook for a quick walkthrough.
The package ships a UNDP-branded template to enhance the look and feel of plotly figures. It is extremely lightweight. Its main features include:
- Colours and colour schemes in line with the UNDP Design System and UNDP data viz library.
Proxima Nova
font settings.- A single dependency (
plotly
).
Note
Plotly uses system fonts. You must have Proxima Nova font installed on your machine for the package to be able to use it. If the font is missing, plotly
will fall back to using some other sans-serif
font without a warning.
All contributions must follow Conventional Commits. The codebase is formatted with black
and isort
. Use the provided Makefile for these routine operations.
- Clone or fork the repository
- Create a new branch (
git checkout -b feature-branch
) - Make your changes
- Ensure your code is properly formatted (
make format
) - Commit your changes (
git commit -m 'Add some feature'
) - Push to the branch (
git push origin feature-branch
) - Open a pull request
This project is licensed under the BSD 3-Clause License. However, entities or individuals not affiliated with UNDP are strictly prohibited from using this package or any of its components to create, share, publish, or distribute works that resemble, claim affiliation with, or imply endorsement by UNDP.
UNDP’s name, emblem and its abbreviation are the exclusive property of UNDP and are protected under international law. Their unauthorized use is prohibited, and they may not be reproduced or used in any manner without UNDP’s prior written permission.
This project is part of Data Futures Exchange (DFx) at UNDP. If you are facing any issues or would like to make some suggestions, feel free to open an issue. For enquiries about DFx, visit Contact Us.