chartaudit 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- chartaudit-0.1.0/.gitignore +9 -0
- chartaudit-0.1.0/CHANGELOG.md +15 -0
- chartaudit-0.1.0/LICENSE +21 -0
- chartaudit-0.1.0/PKG-INFO +165 -0
- chartaudit-0.1.0/README.md +129 -0
- chartaudit-0.1.0/docs/lie_factor_example.svg +25 -0
- chartaudit-0.1.0/pyproject.toml +63 -0
- chartaudit-0.1.0/src/chartaudit/__init__.py +29 -0
- chartaudit-0.1.0/src/chartaudit/_chart.py +354 -0
- chartaudit-0.1.0/src/chartaudit/_data.py +198 -0
- chartaudit-0.1.0/src/chartaudit/_report.py +121 -0
- chartaudit-0.1.0/src/chartaudit/exceptions.py +22 -0
- chartaudit-0.1.0/src/chartaudit/py.typed +0 -0
- chartaudit-0.1.0/tests/conftest.py +12 -0
- chartaudit-0.1.0/tests/test_chart.py +167 -0
- chartaudit-0.1.0/tests/test_data.py +78 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.1.0
|
|
4
|
+
|
|
5
|
+
First release.
|
|
6
|
+
|
|
7
|
+
- `check(fig)` audits a matplotlib figure or Axes: lie factor, data-ink ratio, dual axes,
|
|
8
|
+
3D projections, pies with many slices, rainbow colormaps, missing axis labels, and
|
|
9
|
+
Anscombe checks on scatter data.
|
|
10
|
+
- `lie_factor(ax)`: Tufte's lie factor for bar charts (vertical, horizontal, negative bars;
|
|
11
|
+
truncated and clipped axes).
|
|
12
|
+
- `data_ink_ratio(fig)`: Tufte's data-ink ratio, measured by rendering the figure.
|
|
13
|
+
- `check_data(x, y)`: flags curved relationships, influential outliers and high-leverage
|
|
14
|
+
points hiding behind a correlation or regression line.
|
|
15
|
+
- `load_anscombe()`: Anscombe's quartet for teaching.
|
chartaudit-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Anmol Adhikari
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: chartaudit
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Catch misleading charts and misleading statistics: Tufte's lie factor and data-ink ratio for matplotlib, plus Anscombe-style checks on your data.
|
|
5
|
+
Project-URL: Homepage, https://github.com/AnmolAdhikari/chartaudit
|
|
6
|
+
Project-URL: Issues, https://github.com/AnmolAdhikari/chartaudit/issues
|
|
7
|
+
Project-URL: Changelog, https://github.com/AnmolAdhikari/chartaudit/blob/main/CHANGELOG.md
|
|
8
|
+
Author-email: Anmol Adhikari <anmoladhikari03@gmail.com>
|
|
9
|
+
License-Expression: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: anscombe,chart-linter,data-ink-ratio,data-literacy,data-visualization,lie-factor,matplotlib,statistics,tufte
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Framework :: Matplotlib
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Intended Audience :: Education
|
|
16
|
+
Classifier: Intended Audience :: Science/Research
|
|
17
|
+
Classifier: Operating System :: OS Independent
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
24
|
+
Classifier: Topic :: Education
|
|
25
|
+
Classifier: Topic :: Scientific/Engineering :: Visualization
|
|
26
|
+
Classifier: Typing :: Typed
|
|
27
|
+
Requires-Python: >=3.10
|
|
28
|
+
Requires-Dist: matplotlib>=3.7
|
|
29
|
+
Requires-Dist: numpy>=1.23
|
|
30
|
+
Provides-Extra: dev
|
|
31
|
+
Requires-Dist: build; extra == 'dev'
|
|
32
|
+
Requires-Dist: pytest>=7; extra == 'dev'
|
|
33
|
+
Requires-Dist: ruff; extra == 'dev'
|
|
34
|
+
Requires-Dist: twine; extra == 'dev'
|
|
35
|
+
Description-Content-Type: text/markdown
|
|
36
|
+
|
|
37
|
+
# chartaudit
|
|
38
|
+
|
|
39
|
+
**Catch misleading charts and misleading statistics before your audience does.**
|
|
40
|
+
|
|
41
|
+
`chartaudit` turns three classic ideas from statistics and visualization research into automatic checks:
|
|
42
|
+
|
|
43
|
+
- **Tufte's lie factor:** does the chart exaggerate the difference in the data?
|
|
44
|
+
- **Tufte's data-ink ratio:** how much of the ink actually shows data?
|
|
45
|
+
- **Anscombe's quartet:** does your correlation or regression line hide a curve, an outlier, or a single point doing all the work?
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
pip install chartaudit
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+

|
|
52
|
+
|
|
53
|
+
## Check a chart
|
|
54
|
+
|
|
55
|
+
```python
|
|
56
|
+
import matplotlib.pyplot as plt
|
|
57
|
+
import chartaudit
|
|
58
|
+
|
|
59
|
+
fig, ax = plt.subplots()
|
|
60
|
+
ax.bar(["Us", "Them"], [98, 102])
|
|
61
|
+
ax.set_ylim(95, 104)
|
|
62
|
+
ax.set_title("Customer satisfaction")
|
|
63
|
+
|
|
64
|
+
chartaudit.check(fig)
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
```
|
|
68
|
+
ChartReport
|
|
69
|
+
------------------------------------------------------------
|
|
70
|
+
axes 1
|
|
71
|
+
lie_factor 32.667
|
|
72
|
+
data_ink_ratio 0.955
|
|
73
|
+
|
|
74
|
+
Issues
|
|
75
|
+
[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.
|
|
76
|
+
[INFO ] missing_axis_label: 'Customer satisfaction': no x or y axis label.
|
|
77
|
+
[INFO ] data_ink_ratio: 96% of the ink shows data.
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
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.
|
|
81
|
+
|
|
82
|
+
## Check your data (Anscombe's lesson, automated)
|
|
83
|
+
|
|
84
|
+
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:
|
|
85
|
+
|
|
86
|
+
```python
|
|
87
|
+
x, y = chartaudit.load_anscombe()["III"]
|
|
88
|
+
chartaudit.check_data(x, y)
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
```
|
|
92
|
+
DataReport
|
|
93
|
+
------------------------------------------------------------
|
|
94
|
+
n 11
|
|
95
|
+
mean_x 9.000
|
|
96
|
+
mean_y 7.500
|
|
97
|
+
sd_x 3.317
|
|
98
|
+
sd_y 2.030
|
|
99
|
+
pearson_r 0.816
|
|
100
|
+
spearman_rho 0.991
|
|
101
|
+
slope 0.500
|
|
102
|
+
intercept 3.002
|
|
103
|
+
r2_linear 0.666
|
|
104
|
+
r2_quadratic 0.685
|
|
105
|
+
|
|
106
|
+
Issues
|
|
107
|
+
[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.
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
| Anscombe dataset | What `check_data` reports |
|
|
111
|
+
|---|---|
|
|
112
|
+
| I | no issues: the summary is fair |
|
|
113
|
+
| II | `nonlinear`: a curve fits far better (R² 0.67 → 1.00) |
|
|
114
|
+
| III | `influential_outlier`: one point moves r from 0.816 to 1.000 |
|
|
115
|
+
| IV | `high_leverage`: the whole correlation comes from the point at x = 19 |
|
|
116
|
+
|
|
117
|
+
`check(fig)` runs these data checks automatically on every scatter plot in your figure.
|
|
118
|
+
|
|
119
|
+
## What gets checked
|
|
120
|
+
|
|
121
|
+
| Code | Severity | Meaning |
|
|
122
|
+
|---|---|---|
|
|
123
|
+
| `lie_factor` | error / warning | bar lengths exaggerate or shrink differences (truncated or clipped value axis) |
|
|
124
|
+
| `data_ink_ratio` | info / warning | share of ink that shows data, with concrete tips to raise it |
|
|
125
|
+
| `dual_axis` | warning | two y-axes on one plot (`twinx`) invite comparisons across unrelated scales |
|
|
126
|
+
| `three_d` | warning | 3D projection distorts lengths and angles |
|
|
127
|
+
| `pie_slices` | warning | a pie with more than 5 slices |
|
|
128
|
+
| `rainbow_colormap` | warning | `jet`, `rainbow` and similar colormaps create false boundaries |
|
|
129
|
+
| `missing_axis_label` | info | an axis with data but no label |
|
|
130
|
+
| `nonlinear` | warning | a straight-line summary of a curved relationship |
|
|
131
|
+
| `influential_outlier` | warning | one point changes Pearson's r by more than 0.1 |
|
|
132
|
+
| `high_leverage` | warning | the regression line is forced through a single point |
|
|
133
|
+
|
|
134
|
+
## Use it in tests or CI
|
|
135
|
+
|
|
136
|
+
```python
|
|
137
|
+
def test_report_charts_are_honest():
|
|
138
|
+
fig = make_quarterly_chart()
|
|
139
|
+
chartaudit.check(fig).raise_for_issues() # fails on errors
|
|
140
|
+
chartaudit.check(fig).raise_for_issues(strict=True) # fails on warnings too
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
Reports also render as a table in Jupyter and export with `report.to_dict()`.
|
|
144
|
+
|
|
145
|
+
## How it works
|
|
146
|
+
|
|
147
|
+
- **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.
|
|
148
|
+
- **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.
|
|
149
|
+
- **Anscombe checks** compare linear and quadratic fits, compute leave-one-out correlations (in O(n)) and regression leverage, using NumPy only.
|
|
150
|
+
|
|
151
|
+
## References
|
|
152
|
+
|
|
153
|
+
- Anscombe, F. J. (1973). Graphs in Statistical Analysis. *The American Statistician*, 27(1), 17–21.
|
|
154
|
+
- Tufte, E. R. (1983). *The Visual Display of Quantitative Information*. Graphics Press.
|
|
155
|
+
|
|
156
|
+
## Development
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
pip install -e ".[dev]"
|
|
160
|
+
pytest
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
## License
|
|
164
|
+
|
|
165
|
+
MIT
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
# chartaudit
|
|
2
|
+
|
|
3
|
+
**Catch misleading charts and misleading statistics before your audience does.**
|
|
4
|
+
|
|
5
|
+
`chartaudit` turns three classic ideas from statistics and visualization research into automatic checks:
|
|
6
|
+
|
|
7
|
+
- **Tufte's lie factor:** does the chart exaggerate the difference in the data?
|
|
8
|
+
- **Tufte's data-ink ratio:** how much of the ink actually shows data?
|
|
9
|
+
- **Anscombe's quartet:** does your correlation or regression line hide a curve, an outlier, or a single point doing all the work?
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
pip install chartaudit
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+

|
|
16
|
+
|
|
17
|
+
## Check a chart
|
|
18
|
+
|
|
19
|
+
```python
|
|
20
|
+
import matplotlib.pyplot as plt
|
|
21
|
+
import chartaudit
|
|
22
|
+
|
|
23
|
+
fig, ax = plt.subplots()
|
|
24
|
+
ax.bar(["Us", "Them"], [98, 102])
|
|
25
|
+
ax.set_ylim(95, 104)
|
|
26
|
+
ax.set_title("Customer satisfaction")
|
|
27
|
+
|
|
28
|
+
chartaudit.check(fig)
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
```
|
|
32
|
+
ChartReport
|
|
33
|
+
------------------------------------------------------------
|
|
34
|
+
axes 1
|
|
35
|
+
lie_factor 32.667
|
|
36
|
+
data_ink_ratio 0.955
|
|
37
|
+
|
|
38
|
+
Issues
|
|
39
|
+
[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.
|
|
40
|
+
[INFO ] missing_axis_label: 'Customer satisfaction': no x or y axis label.
|
|
41
|
+
[INFO ] data_ink_ratio: 96% of the ink shows data.
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
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.
|
|
45
|
+
|
|
46
|
+
## Check your data (Anscombe's lesson, automated)
|
|
47
|
+
|
|
48
|
+
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:
|
|
49
|
+
|
|
50
|
+
```python
|
|
51
|
+
x, y = chartaudit.load_anscombe()["III"]
|
|
52
|
+
chartaudit.check_data(x, y)
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
```
|
|
56
|
+
DataReport
|
|
57
|
+
------------------------------------------------------------
|
|
58
|
+
n 11
|
|
59
|
+
mean_x 9.000
|
|
60
|
+
mean_y 7.500
|
|
61
|
+
sd_x 3.317
|
|
62
|
+
sd_y 2.030
|
|
63
|
+
pearson_r 0.816
|
|
64
|
+
spearman_rho 0.991
|
|
65
|
+
slope 0.500
|
|
66
|
+
intercept 3.002
|
|
67
|
+
r2_linear 0.666
|
|
68
|
+
r2_quadratic 0.685
|
|
69
|
+
|
|
70
|
+
Issues
|
|
71
|
+
[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.
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
| Anscombe dataset | What `check_data` reports |
|
|
75
|
+
|---|---|
|
|
76
|
+
| I | no issues: the summary is fair |
|
|
77
|
+
| II | `nonlinear`: a curve fits far better (R² 0.67 → 1.00) |
|
|
78
|
+
| III | `influential_outlier`: one point moves r from 0.816 to 1.000 |
|
|
79
|
+
| IV | `high_leverage`: the whole correlation comes from the point at x = 19 |
|
|
80
|
+
|
|
81
|
+
`check(fig)` runs these data checks automatically on every scatter plot in your figure.
|
|
82
|
+
|
|
83
|
+
## What gets checked
|
|
84
|
+
|
|
85
|
+
| Code | Severity | Meaning |
|
|
86
|
+
|---|---|---|
|
|
87
|
+
| `lie_factor` | error / warning | bar lengths exaggerate or shrink differences (truncated or clipped value axis) |
|
|
88
|
+
| `data_ink_ratio` | info / warning | share of ink that shows data, with concrete tips to raise it |
|
|
89
|
+
| `dual_axis` | warning | two y-axes on one plot (`twinx`) invite comparisons across unrelated scales |
|
|
90
|
+
| `three_d` | warning | 3D projection distorts lengths and angles |
|
|
91
|
+
| `pie_slices` | warning | a pie with more than 5 slices |
|
|
92
|
+
| `rainbow_colormap` | warning | `jet`, `rainbow` and similar colormaps create false boundaries |
|
|
93
|
+
| `missing_axis_label` | info | an axis with data but no label |
|
|
94
|
+
| `nonlinear` | warning | a straight-line summary of a curved relationship |
|
|
95
|
+
| `influential_outlier` | warning | one point changes Pearson's r by more than 0.1 |
|
|
96
|
+
| `high_leverage` | warning | the regression line is forced through a single point |
|
|
97
|
+
|
|
98
|
+
## Use it in tests or CI
|
|
99
|
+
|
|
100
|
+
```python
|
|
101
|
+
def test_report_charts_are_honest():
|
|
102
|
+
fig = make_quarterly_chart()
|
|
103
|
+
chartaudit.check(fig).raise_for_issues() # fails on errors
|
|
104
|
+
chartaudit.check(fig).raise_for_issues(strict=True) # fails on warnings too
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Reports also render as a table in Jupyter and export with `report.to_dict()`.
|
|
108
|
+
|
|
109
|
+
## How it works
|
|
110
|
+
|
|
111
|
+
- **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.
|
|
112
|
+
- **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.
|
|
113
|
+
- **Anscombe checks** compare linear and quadratic fits, compute leave-one-out correlations (in O(n)) and regression leverage, using NumPy only.
|
|
114
|
+
|
|
115
|
+
## References
|
|
116
|
+
|
|
117
|
+
- Anscombe, F. J. (1973). Graphs in Statistical Analysis. *The American Statistician*, 27(1), 17–21.
|
|
118
|
+
- Tufte, E. R. (1983). *The Visual Display of Quantitative Information*. Graphics Press.
|
|
119
|
+
|
|
120
|
+
## Development
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
pip install -e ".[dev]"
|
|
124
|
+
pytest
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## License
|
|
128
|
+
|
|
129
|
+
MIT
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="640" height="260" viewBox="0 0 640 260" font-family="Helvetica, Arial, sans-serif" fill="#222">
|
|
2
|
+
<rect width="640" height="260" fill="#fff"/>
|
|
3
|
+
<text x="175.0" y="24" text-anchor="middle" font-size="14" font-weight="600" fill="#c0392b">Misleading: lie factor 32.7</text>
|
|
4
|
+
<rect x="85" y="146.2" width="70" height="63.8" fill="#9aa5b1"/>
|
|
5
|
+
<text x="120" y="228" text-anchor="middle" font-size="12">Product A</text>
|
|
6
|
+
<rect x="195" y="61.2" width="70" height="148.8" fill="#2563eb"/>
|
|
7
|
+
<text x="230" y="228" text-anchor="middle" font-size="12">Product B</text>
|
|
8
|
+
<path d="M60 40 V210 H290" stroke="#333" fill="none"/>
|
|
9
|
+
<path d="M56 210.0 H60" stroke="#333"/><text x="53" y="214.0" text-anchor="end" font-size="11">95</text>
|
|
10
|
+
<path d="M56 167.5 H60" stroke="#333"/><text x="53" y="171.5" text-anchor="end" font-size="11">97</text>
|
|
11
|
+
<path d="M56 125.0 H60" stroke="#333"/><text x="53" y="129.0" text-anchor="end" font-size="11">99</text>
|
|
12
|
+
<path d="M56 82.5 H60" stroke="#333"/><text x="53" y="86.5" text-anchor="end" font-size="11">101</text>
|
|
13
|
+
<path d="M56 40.0 H60" stroke="#333"/><text x="53" y="44.0" text-anchor="end" font-size="11">103</text>
|
|
14
|
+
<text x="495.0" y="24" text-anchor="middle" font-size="14" font-weight="600" fill="#1e7e34">Honest: lie factor 1.0</text>
|
|
15
|
+
<rect x="405" y="58.5" width="70" height="151.5" fill="#9aa5b1"/>
|
|
16
|
+
<text x="440" y="228" text-anchor="middle" font-size="12">Product A</text>
|
|
17
|
+
<rect x="515" y="52.4" width="70" height="157.6" fill="#2563eb"/>
|
|
18
|
+
<text x="550" y="228" text-anchor="middle" font-size="12">Product B</text>
|
|
19
|
+
<path d="M380 40 V210 H610" stroke="#333" fill="none"/>
|
|
20
|
+
<path d="M376 210.0 H380" stroke="#333"/><text x="373" y="214.0" text-anchor="end" font-size="11">0</text>
|
|
21
|
+
<path d="M376 171.4 H380" stroke="#333"/><text x="373" y="175.4" text-anchor="end" font-size="11">25</text>
|
|
22
|
+
<path d="M376 132.7 H380" stroke="#333"/><text x="373" y="136.7" text-anchor="end" font-size="11">50</text>
|
|
23
|
+
<path d="M376 94.1 H380" stroke="#333"/><text x="373" y="98.1" text-anchor="end" font-size="11">75</text>
|
|
24
|
+
<path d="M376 55.5 H380" stroke="#333"/><text x="373" y="59.5" text-anchor="end" font-size="11">100</text>
|
|
25
|
+
</svg>
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling>=1.24"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "chartaudit"
|
|
7
|
+
dynamic = ["version"]
|
|
8
|
+
description = "Catch misleading charts and misleading statistics: Tufte's lie factor and data-ink ratio for matplotlib, plus Anscombe-style checks on your data."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "MIT"
|
|
11
|
+
license-files = ["LICENSE"]
|
|
12
|
+
requires-python = ">=3.10"
|
|
13
|
+
authors = [{ name = "Anmol Adhikari", email = "anmoladhikari03@gmail.com" }]
|
|
14
|
+
keywords = [
|
|
15
|
+
"matplotlib", "data-visualization", "tufte", "lie-factor", "data-ink-ratio",
|
|
16
|
+
"anscombe", "chart-linter", "statistics", "data-literacy",
|
|
17
|
+
]
|
|
18
|
+
classifiers = [
|
|
19
|
+
"Development Status :: 4 - Beta",
|
|
20
|
+
"Framework :: Matplotlib",
|
|
21
|
+
"Intended Audience :: Education",
|
|
22
|
+
"Intended Audience :: Science/Research",
|
|
23
|
+
"Intended Audience :: Developers",
|
|
24
|
+
"Operating System :: OS Independent",
|
|
25
|
+
"Programming Language :: Python :: 3",
|
|
26
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
27
|
+
"Programming Language :: Python :: 3.10",
|
|
28
|
+
"Programming Language :: Python :: 3.11",
|
|
29
|
+
"Programming Language :: Python :: 3.12",
|
|
30
|
+
"Programming Language :: Python :: 3.13",
|
|
31
|
+
"Topic :: Scientific/Engineering :: Visualization",
|
|
32
|
+
"Topic :: Education",
|
|
33
|
+
"Typing :: Typed",
|
|
34
|
+
]
|
|
35
|
+
dependencies = ["matplotlib>=3.7", "numpy>=1.23"]
|
|
36
|
+
|
|
37
|
+
[project.optional-dependencies]
|
|
38
|
+
dev = ["pytest>=7", "build", "twine", "ruff"]
|
|
39
|
+
|
|
40
|
+
[project.urls]
|
|
41
|
+
Homepage = "https://github.com/AnmolAdhikari/chartaudit"
|
|
42
|
+
Issues = "https://github.com/AnmolAdhikari/chartaudit/issues"
|
|
43
|
+
Changelog = "https://github.com/AnmolAdhikari/chartaudit/blob/main/CHANGELOG.md"
|
|
44
|
+
|
|
45
|
+
[tool.hatch.version]
|
|
46
|
+
path = "src/chartaudit/__init__.py"
|
|
47
|
+
|
|
48
|
+
[tool.hatch.build.targets.wheel]
|
|
49
|
+
packages = ["src/chartaudit"]
|
|
50
|
+
|
|
51
|
+
[tool.hatch.build.targets.sdist]
|
|
52
|
+
include = ["src", "tests", "docs", "README.md", "CHANGELOG.md", "LICENSE"]
|
|
53
|
+
|
|
54
|
+
[tool.pytest.ini_options]
|
|
55
|
+
testpaths = ["tests"]
|
|
56
|
+
addopts = "-ra"
|
|
57
|
+
|
|
58
|
+
[tool.ruff]
|
|
59
|
+
line-length = 110
|
|
60
|
+
target-version = "py310"
|
|
61
|
+
|
|
62
|
+
[tool.ruff.lint]
|
|
63
|
+
select = ["E", "F", "I", "B", "UP"]
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"""chartaudit - catch misleading charts and misleading summary statistics.
|
|
2
|
+
|
|
3
|
+
* ``check(fig)`` audit a matplotlib figure (lie factor, data-ink ratio, ...)
|
|
4
|
+
* ``check_data(x, y)`` Anscombe checks: does r / the regression line tell the truth?
|
|
5
|
+
* ``lie_factor(ax)`` Tufte's lie factor for the bar series on an Axes
|
|
6
|
+
* ``data_ink_ratio(fig)`` Tufte's data-ink ratio of a rendered figure
|
|
7
|
+
* ``load_anscombe()`` Anscombe's quartet, for teaching and demos
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from __future__ import annotations
|
|
11
|
+
|
|
12
|
+
from ._chart import LieFactor, check, data_ink_ratio, lie_factor
|
|
13
|
+
from ._data import check_data, load_anscombe
|
|
14
|
+
from ._report import Issue, Report
|
|
15
|
+
from .exceptions import ChartAuditError
|
|
16
|
+
|
|
17
|
+
__all__ = [
|
|
18
|
+
"ChartAuditError",
|
|
19
|
+
"Issue",
|
|
20
|
+
"LieFactor",
|
|
21
|
+
"Report",
|
|
22
|
+
"check",
|
|
23
|
+
"check_data",
|
|
24
|
+
"data_ink_ratio",
|
|
25
|
+
"lie_factor",
|
|
26
|
+
"load_anscombe",
|
|
27
|
+
]
|
|
28
|
+
|
|
29
|
+
__version__ = "0.1.0"
|