chartaudit
Catch misleading charts and misleading statistics before your audience does.
chartaudit turns three classic ideas from statistics and visualization research into automatic checks:
- Tufte's lie factor: does the chart exaggerate the difference in the data?
- Tufte's data-ink ratio: how much of the ink actually shows data?
- Anscombe's quartet: does your correlation or regression line hide a curve, an outlier, or a single point doing all the work?
pip install chartaudit
Check a chart
import matplotlib.pyplot as plt
import chartaudit
fig, ax = plt.subplots()
ax.bar(["Us", "Them"], [98, 102])
ax.set_ylim(95, 104)
ax.set_title("Customer satisfaction")
chartaudit.check(fig)
ChartReport
------------------------------------------------------------
axes 1
lie_factor 32.667
data_ink_ratio 0.955
Issues
[ERROR] lie_factor: 'Customer satisfaction': lie factor 32.67. The largest bar looks 2.33x the smallest but the data ratio is 1.04x (102 vs 98) because the y-axis starts at 95, not 0.
[INFO ] missing_axis_label: 'Customer satisfaction': no x or y axis label.
[INFO ] data_ink_ratio: 96% of the ink shows data.
A 4% difference drawn as a 133% difference: the chart exaggerates the effect 32.7 times. Tufte's tolerance is 0.95 to 1.05.
Check your data (Anscombe's lesson, automated)
All four datasets in Anscombe's quartet share the same means, variances, correlation (r = 0.816) and regression line, yet they look completely different. check_data finds out which one you have:
x, y = chartaudit.load_anscombe()["III"]
chartaudit.check_data(x, y)
DataReport
------------------------------------------------------------
n 11
mean_x 9.000
mean_y 7.500
sd_x 3.317
sd_y 2.030
pearson_r 0.816
spearman_rho 0.991
slope 0.500
intercept 3.002
r2_linear 0.666
r2_quadratic 0.685
Issues
[WARN ] influential_outlier: removing the point (x=13, y=12.74) changes Pearson's r from 0.816 to 1.000. One point is shaping the summary.
| Anscombe dataset | What check_data reports |
|---|---|
| I | no issues: the summary is fair |
| II | nonlinear: a curve fits far better (R² 0.67 → 1.00) |
| III | influential_outlier: one point moves r from 0.816 to 1.000 |
| IV | high_leverage: the whole correlation comes from the point at x = 19 |
check(fig) runs these data checks automatically on every scatter plot in your figure.
What gets checked
| Code | Severity | Meaning |
|---|---|---|
lie_factor |
error / warning | bar lengths exaggerate or shrink differences (truncated or clipped value axis) |
data_ink_ratio |
info / warning | share of ink that shows data, with concrete tips to raise it |
dual_axis |
warning | two y-axes on one plot (twinx) invite comparisons across unrelated scales |
three_d |
warning | 3D projection distorts lengths and angles |
pie_slices |
warning | a pie with more than 5 slices |
rainbow_colormap |
warning | jet, rainbow and similar colormaps create false boundaries |
missing_axis_label |
info | an axis with data but no label |
nonlinear |
warning | a straight-line summary of a curved relationship |
influential_outlier |
warning | one point changes Pearson's r by more than 0.1 |
high_leverage |
warning | the regression line is forced through a single point |
Use it in tests or CI
def test_report_charts_are_honest():
fig = make_quarterly_chart()
chartaudit.check(fig).raise_for_issues() # fails on errors
chartaudit.check(fig).raise_for_issues(strict=True) # fails on warnings too
Reports also render as a table in Jupyter and export with report.to_dict().
How it works
- Lie factor is
visual effect / data effect(Tufte, 1983), where an effect is the relative difference between the smallest and largest bar. The visual size of each bar is computed from the axis limits, so truncated and clipped axes are measured exactly. Stacked, mixed-sign and log-scale bars are skipped, because the formula does not apply to them. - Data-ink ratio renders the figure twice, once as is and once with only the data marks, and compares the ink (each pixel's colour distance from the background). Axes, ticks, gridlines, labels, legends, titles, colorbars and coloured backgrounds count as non-data ink.
- Anscombe checks compare linear and quadratic fits, compute leave-one-out correlations (in O(n)) and regression leverage, using NumPy only.
References
- Anscombe, F. J. (1973). Graphs in Statistical Analysis. The American Statistician, 27(1), 17–21.
- Tufte, E. R. (1983). The Visual Display of Quantitative Information. Graphics Press.
Development
pip install -e ".[dev]"
pytest
License
MIT
Metadata
Release files for chartaudit 0.1.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 |
|---|---|---|---|---|
| chartaudit-0.1.0.tar.gz | 16.6 kB | With provenance | Details for chartaudit-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| chartaudit-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for chartaudit-0.1.0-py3-none-any.whl |
Total release size: 32.1 kB
Release files / chartaudit-0.1.0.tar.gz
| Download URL | chartaudit-0.1.0.tar.gz |
|---|---|
| Size | 16.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
535d3fa07d0efa5b6fa858f393a834cd09540beebc456c4748866efdc91efdea
|
|
BLAKE2b-256 checksum How to use checksums |
f065bf0f99ec093d0931e7256ad18086c1c6bada1c8e4a32a13bdb80e16dbccc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Dec 2, 2026.
Transparency logRelease files / chartaudit-0.1.0-py3-none-any.whl
| Download URL | chartaudit-0.1.0-py3-none-any.whl |
|---|---|
| Size | 15.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
eff16334d5da2d1c4daaf155277490be32e651aade9235790ecb74c46308ac9b
|
|
BLAKE2b-256 checksum How to use checksums |
9200fa3afa7d729aea541c67d439c67685e243ca1c2a5924dd6c9395a7e36ac3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Dec 2, 2026.
Transparency logSecurity for chartaudit 0.1.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 chartaudit-0.1.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 Dec 2, 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.