afcharts-py 
Overview
The afcharts python package helps make accessible Matplotlib and Plotly charts following Government Analysis Function Data Visualisation guidance:
- Automatic chart formatting with pre-built style sheets for Matplotlib and Plotly
- Chart colours from the Analysis Function accessible colour palettes
- Example code for common chart types in the cookbook
Looking for the R version? Check out the afcharts R package.
Installation
afcharts is available at the Python Package Index (PyPI):
pip install afcharts
To install a compatible version of Matplotlib or Plotly alongside afcharts, use:
# Matplotlib
pip install "afcharts[matplotlib]"
# Plotly
pip install "afcharts[plotly]"
See the installation guide for more detailed instructions and alternative installation methods.
Usage
Format any Matplotlib or Plotly chart in the Analysis Function style using the built-in style sheets.
See the Getting Started guide for more options and the cookbook for extensive examples.
Matplotlib
import matplotlib.pyplot as plt
# Apply the afcharts style to all Matplotlib plots
plt.style.use('afcharts.afcharts')
Example: A Matplotlib bar chart with afcharts (left) and without (right)
Plotly
from afcharts.pio_template import pio
# Apply the afcharts style to all Plotly plots
pio.templates.default = "afcharts"
Example: A Plotly bar chart with afcharts (left) and without (right)
Colours
Easily return a list of colours from any of the Analysis Function accessible colour palettes with the get_af_colours() function:
from afcharts.af_colours import get_af_colours
# Get the duo colour palette hex codes
duo = get_af_colours("duo")
Getting help
If you encounter a bug, please file a minimal reproducible example on Github Issues. For questions and other discussion, please start a discussion.
Contributing
Interested in contributing? Check out the contributing guidelines.
Acknowledgments
The afcharts python package is based on the afcharts R package and the py-af-colours package.
License
Unless stated otherwise, the codebase is released under the MIT License. This covers both the codebase and any sample code in the documentation.
The documentation is © Crown copyright and available under the terms of the Open Government 3.0 licence.
Metadata
Release files for afcharts 1.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| afcharts-1.2.0.tar.gz | 12.0 kB | With provenance | Details for afcharts-1.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| afcharts-1.2.0-py3-none-any.whl | Python 3 | none | any | Details for afcharts-1.2.0-py3-none-any.whl |
Total release size: 21.8 kB
Release files / afcharts-1.2.0.tar.gz
| Download URL | afcharts-1.2.0.tar.gz |
|---|---|
| Size | 12.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2708e35f5e0e99debc1e19fc45e7210b358655e78b8daee52b794f7dcc29ee54
|
|
BLAKE2b-256 checksum How to use checksums |
5a7ddeff44c92ccdb9cc14be625bcf3946548249a00fcf23fde342bd3c75e2f3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 20, 2026.
Transparency logRelease files / afcharts-1.2.0-py3-none-any.whl
| Download URL | afcharts-1.2.0-py3-none-any.whl |
|---|---|
| Size | 9.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e86a966f3167a2555f8cc6c35aa51539654f3b5965ba570164ef193860ce53e9
|
|
BLAKE2b-256 checksum How to use checksums |
0d371cc35ee2331ff4cc04b6171e512c12432d1e9fecbf0b40fcc62008d56652
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 20, 2026.
Transparency logSecurity for afcharts 1.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for afcharts-1.2.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 20, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.