plotlibs 0.3.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.
- plotlibs-0.3.0/LICENSE +21 -0
- plotlibs-0.3.0/PKG-INFO +228 -0
- plotlibs-0.3.0/README.md +176 -0
- plotlibs-0.3.0/plotlib/__init__.py +38 -0
- plotlibs-0.3.0/plotlibs/__init__.py +110 -0
- plotlibs-0.3.0/plotlibs/backends/__init__.py +0 -0
- plotlibs-0.3.0/plotlibs/backends/renderer.py +520 -0
- plotlibs-0.3.0/plotlibs/colors.py +107 -0
- plotlibs-0.3.0/plotlibs/data.py +208 -0
- plotlibs-0.3.0/plotlibs/db.py +204 -0
- plotlibs-0.3.0/plotlibs/eda.py +157 -0
- plotlibs-0.3.0/plotlibs/fast.py +187 -0
- plotlibs-0.3.0/plotlibs/figure.py +617 -0
- plotlibs-0.3.0/plotlibs/ml.py +205 -0
- plotlibs-0.3.0/plotlibs/pyplot.py +283 -0
- plotlibs-0.3.0/plotlibs/style.py +96 -0
- plotlibs-0.3.0/plotlibs.egg-info/PKG-INFO +228 -0
- plotlibs-0.3.0/plotlibs.egg-info/SOURCES.txt +24 -0
- plotlibs-0.3.0/plotlibs.egg-info/dependency_links.txt +1 -0
- plotlibs-0.3.0/plotlibs.egg-info/requires.txt +28 -0
- plotlibs-0.3.0/plotlibs.egg-info/top_level.txt +2 -0
- plotlibs-0.3.0/pyproject.toml +49 -0
- plotlibs-0.3.0/setup.cfg +4 -0
- plotlibs-0.3.0/tests/test_fame.py +82 -0
- plotlibs-0.3.0/tests/test_plotlib.py +47 -0
- plotlibs-0.3.0/tests/test_rebrand.py +45 -0
plotlibs-0.3.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 salim-studio
|
|
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.
|
plotlibs-0.3.0/PKG-INFO
ADDED
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: plotlibs
|
|
3
|
+
Version: 0.3.0
|
|
4
|
+
Summary: plotlibs — fast, beautiful, matplotlib-compatible plotting with DataFrames, SQL, EDA and ML/DL visuals (numpy + Pillow only)
|
|
5
|
+
Author: salim-studio
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/salim-studio/plotlibs
|
|
8
|
+
Project-URL: Repository, https://github.com/salim-studio/plotlibs
|
|
9
|
+
Project-URL: Issues, https://github.com/salim-studio/plotlibs/issues
|
|
10
|
+
Project-URL: Documentation, https://github.com/salim-studio/plotlibs#readme
|
|
11
|
+
Project-URL: Changelog, https://github.com/salim-studio/plotlibs/blob/main/CHANGELOG.md
|
|
12
|
+
Keywords: plotting,matplotlib,visualization,dataframe,sql,eda,machine-learning,deep-learning,pandas
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Intended Audience :: Science/Research
|
|
16
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Classifier: Topic :: Scientific/Engineering :: Visualization
|
|
23
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
24
|
+
Classifier: Topic :: Database
|
|
25
|
+
Requires-Python: >=3.9
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
License-File: LICENSE
|
|
28
|
+
Requires-Dist: numpy
|
|
29
|
+
Requires-Dist: pillow
|
|
30
|
+
Provides-Extra: data
|
|
31
|
+
Requires-Dist: pandas>=1.5; extra == "data"
|
|
32
|
+
Requires-Dist: pyarrow>=10; extra == "data"
|
|
33
|
+
Provides-Extra: db
|
|
34
|
+
Requires-Dist: sqlalchemy>=2.0; extra == "db"
|
|
35
|
+
Requires-Dist: duckdb>=0.8; extra == "db"
|
|
36
|
+
Provides-Extra: ml
|
|
37
|
+
Requires-Dist: scikit-learn>=1.0; extra == "ml"
|
|
38
|
+
Requires-Dist: pandas>=1.5; extra == "ml"
|
|
39
|
+
Provides-Extra: all
|
|
40
|
+
Requires-Dist: pandas>=1.5; extra == "all"
|
|
41
|
+
Requires-Dist: pyarrow>=10; extra == "all"
|
|
42
|
+
Requires-Dist: sqlalchemy>=2.0; extra == "all"
|
|
43
|
+
Requires-Dist: duckdb>=0.8; extra == "all"
|
|
44
|
+
Requires-Dist: scikit-learn>=1.0; extra == "all"
|
|
45
|
+
Requires-Dist: matplotlib>=3.5; extra == "all"
|
|
46
|
+
Provides-Extra: dev
|
|
47
|
+
Requires-Dist: matplotlib; extra == "dev"
|
|
48
|
+
Requires-Dist: pytest; extra == "dev"
|
|
49
|
+
Requires-Dist: pandas; extra == "dev"
|
|
50
|
+
Requires-Dist: scikit-learn; extra == "dev"
|
|
51
|
+
Dynamic: license-file
|
|
52
|
+
|
|
53
|
+
<p align="center">
|
|
54
|
+
<img src="assets/banner.svg" alt="plotlibs banner" width="100%"/>
|
|
55
|
+
</p>
|
|
56
|
+
|
|
57
|
+
<p align="center">
|
|
58
|
+
<img src="assets/logo.svg" alt="plotlibs logo" width="96"/>
|
|
59
|
+
</p>
|
|
60
|
+
|
|
61
|
+
<h1 align="center">plotlibs</h1>
|
|
62
|
+
<p align="center"><b>Fast, beautiful Python plotting for everyone.</b></p>
|
|
63
|
+
|
|
64
|
+
<p align="center">
|
|
65
|
+
<a href="https://github.com/salim-studio/plotlibs"><img src="https://img.shields.io/badge/github-salim--studio%2Fplotlibs-0F172A?logo=github" alt="GitHub"/></a>
|
|
66
|
+
<img src="https://img.shields.io/badge/version-0.3.0-4F46E5" alt="version"/>
|
|
67
|
+
<img src="https://img.shields.io/badge/speed-~4x_vs_matplotlib-06B6D4" alt="speed"/>
|
|
68
|
+
<img src="https://img.shields.io/badge/deps-numpy_%2B_pillow_only-A3E635" alt="deps"/>
|
|
69
|
+
<img src="https://img.shields.io/badge/license-MIT-FACC15" alt="license"/>
|
|
70
|
+
<img src="https://img.shields.io/badge/python-%3E%3D3.9-3776AB?logo=python&logoColor=white" alt="python"/>
|
|
71
|
+
</p>
|
|
72
|
+
|
|
73
|
+
> **Renamed:** `plotlib` → **`plotlibs`**.
|
|
74
|
+
> Old code keeps working via a shim (`import plotlib`), but please migrate to `import plotlibs`.
|
|
75
|
+
> New home: **https://github.com/salim-studio/plotlibs**
|
|
76
|
+
|
|
77
|
+
```python
|
|
78
|
+
import plotlibs as pl
|
|
79
|
+
|
|
80
|
+
pl.plot([1, 2, 3], [1, 4, 9], label="x²")
|
|
81
|
+
pl.xlabel("x"); pl.ylabel("y"); pl.legend()
|
|
82
|
+
pl.savefig("out.png") # or pl.show()
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Why plotlibs?
|
|
86
|
+
|
|
87
|
+
| Audience | One-liner value |
|
|
88
|
+
|---|---|
|
|
89
|
+
| Developers | Matplotlib-compatible API, only `numpy + pillow`, ~4x faster on big data |
|
|
90
|
+
| Data analysts | `pl.load_csv` → `pl.quick_eda(df)` → `boxplot / kde / heatmap / countplot` |
|
|
91
|
+
| Databases | `pl.db_connect("sales.db")` + `pl.read_sql(...)` + `plot_from_sql(...)` (sqlite / SQLAlchemy / DuckDB) |
|
|
92
|
+
| Machine learning | `plot_confusion_matrix`, `plot_roc`, `plot_pr`, `feature_importance`, `residuals`, `elbow` |
|
|
93
|
+
| Deep learning | `plot_history`, `plot_images`, `plot_clusters_2d` |
|
|
94
|
+
|
|
95
|
+
## Install
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
pip install plotlibs # minimal: numpy + pillow
|
|
99
|
+
pip install "plotlibs[all]" # pandas + sqlalchemy + duckdb + sklearn + matplotlib
|
|
100
|
+
pip install -e ".[dev]" # contributors
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## 30-second tour
|
|
104
|
+
|
|
105
|
+
```python
|
|
106
|
+
import plotlibs as pl
|
|
107
|
+
|
|
108
|
+
# 1) EDA in one line
|
|
109
|
+
df = pl.load_csv("sales.csv")
|
|
110
|
+
print(pl.describe(df))
|
|
111
|
+
pl.quick_eda(df)
|
|
112
|
+
|
|
113
|
+
# 2) Stats plots (all matplotlib-style signatures)
|
|
114
|
+
pl.boxplot([[1, 2, 3], [2, 3, 4]], labels=["A", "B"])
|
|
115
|
+
pl.violinplot([[1, 2, 3], [2, 3, 4]])
|
|
116
|
+
pl.kde(df["sales"])
|
|
117
|
+
pl.heatmap([[1, 0.8], [0.8, 1]], annot=True)
|
|
118
|
+
pl.corr(df, annot=True)
|
|
119
|
+
pl.countplot(["Cairo", "Oran", "Cairo"])
|
|
120
|
+
pl.area([1, 2, 3], [1, 1, 1], [2, 2, 2], labels=["a", "b"])
|
|
121
|
+
pl.hist2d([1, 2, 2, 3], [1, 1, 2, 2])
|
|
122
|
+
pl.stem([1, 2, 3], [2, 1, 3])
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
```python
|
|
126
|
+
# 3) SQL -> plot
|
|
127
|
+
conn = pl.db_connect("sales.db") # or ":memory:", "sqlite:///x.db", "duckdb://shop.ddb"
|
|
128
|
+
pl.to_sql(df, "sales", conn)
|
|
129
|
+
print(pl.db.list_tables(conn))
|
|
130
|
+
df2 = pl.read_sql("SELECT region, SUM(amount) FROM sales GROUP BY region", conn)
|
|
131
|
+
pl.db.plot_from_sql("SELECT qty, amount FROM sales LIMIT 500", conn, kind="scatter")
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
```python
|
|
135
|
+
# 4) ML / DL
|
|
136
|
+
pl.plot_history({"loss": [0.9, 0.5, 0.3], "val_loss": [1.0, 0.6, 0.4]})
|
|
137
|
+
pl.plot_confusion_matrix(y_true, y_pred, normalize=True)
|
|
138
|
+
pl.plot_roc(y_true, y_score, label="xgb")
|
|
139
|
+
pl.plot_feature_importance(["age", "salary", "city"], [0.5, 0.3, 0.2])
|
|
140
|
+
pl.plot_images(mnist_images)
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
## Visual identity
|
|
144
|
+
|
|
145
|
+
Brand: **midnight ink `#0F172A` + indigo `#4F46E5` + cyan `#06B6D4`**, highlights lime `#A3E635` / amber `#FACC15`, background paper `#F8FAFC`. Logo: rounded-square gradient with a white line chart. See [`assets/`](assets/) and [`BRANDING.md`](BRANDING.md).
|
|
146
|
+
|
|
147
|
+
Signature theme:
|
|
148
|
+
|
|
149
|
+
```python
|
|
150
|
+
import plotlibs as pl
|
|
151
|
+
pl.style.use("plotlibs") # light signature
|
|
152
|
+
pl.style.use("plotlibs-dark") # dark signature
|
|
153
|
+
print(pl.style.available())
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
| Token | Hex | Use |
|
|
157
|
+
|---|---|---|
|
|
158
|
+
| primary | `#4F46E5` | lines, logo start, links |
|
|
159
|
+
| accent | `#06B6D4` | second series, banner end |
|
|
160
|
+
| ink | `#0F172A` | text, dark backgrounds |
|
|
161
|
+
| paper | `#F8FAFC` | page background |
|
|
162
|
+
| lime | `#A3E635` | highlight dots |
|
|
163
|
+
| amber | `#FACC15` | highlight dots |
|
|
164
|
+
|
|
165
|
+
## Matplotlib compatibility
|
|
166
|
+
|
|
167
|
+
| matplotlib | plotlibs 0.3.0 |
|
|
168
|
+
|---|---|
|
|
169
|
+
| `plot / scatter / bar / hist / imshow / pie / fill_between / step / errorbar` | ✅ same signature |
|
|
170
|
+
| `boxplot / violinplot / hist2d / stem / stackplot` | ✅ |
|
|
171
|
+
| `xlabel / ylabel / title / legend / grid / xlim / ylim / savefig / show / subplots` | ✅ |
|
|
172
|
+
| `style.use / rcParams` | ✅ + `plotlibs`, `plotlibs-dark`, `seaborn`, `plotly`, `publication` |
|
|
173
|
+
|
|
174
|
+
## Why faster?
|
|
175
|
+
|
|
176
|
+
1. **Min-max decimation** — lines over 2000 points are bucketed (min+max preserved), `O(n)` in numpy.
|
|
177
|
+
2. **Pillow rasterizer** — direct C-level drawing, no heavy layout engine.
|
|
178
|
+
3. **Vectorized pipeline** — data→pixel in one pass, numpy ticks/limits.
|
|
179
|
+
4. **No heavy objects** — artists are plain dicts, render is deferred.
|
|
180
|
+
|
|
181
|
+
Benchmark (`n=200k`, `benchmarks/bench.py`):
|
|
182
|
+
|
|
183
|
+
```
|
|
184
|
+
plotlibs : ~370 ms/plot
|
|
185
|
+
matplotlib : ~1560 ms/plot
|
|
186
|
+
speedup : ~4.2x faster
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
## Project layout
|
|
190
|
+
|
|
191
|
+
```
|
|
192
|
+
plotlibs/ # repo root (package name == repo name)
|
|
193
|
+
plotlibs/ # real package
|
|
194
|
+
__init__.py pyplot.py figure.py colors.py fast.py style.py
|
|
195
|
+
data.py db.py eda.py ml.py
|
|
196
|
+
backends/renderer.py
|
|
197
|
+
plotlib/ # deprecated shim (renamed alias)
|
|
198
|
+
assets/ # logo.svg, banner.svg
|
|
199
|
+
tests/ benchmarks/ examples/
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
## Migration from `plotlib`
|
|
203
|
+
|
|
204
|
+
```diff
|
|
205
|
+
- import plotlib as pl
|
|
206
|
+
+ import plotlibs as pl
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
`import plotlib` still works in 0.3.x (emits `DeprecationWarning`) and will be removed in 1.0.
|
|
210
|
+
|
|
211
|
+
## Roadmap
|
|
212
|
+
|
|
213
|
+
- [x] 0.3.0 — Rename to **plotlibs**, English docs, brand identity (this release)
|
|
214
|
+
- [ ] 0.4.0 — Interactive HTML export (`pl.save_html`), dashboards, RTL/Arabic labels
|
|
215
|
+
- [ ] 0.5.0 — Geo + time-series + sklearn/HF pipeline helpers
|
|
216
|
+
- Suggest ideas: open an issue with `[idea]` at https://github.com/salim-studio/plotlibs/issues
|
|
217
|
+
|
|
218
|
+
## Contributing
|
|
219
|
+
|
|
220
|
+
```bash
|
|
221
|
+
python -m pytest tests -q
|
|
222
|
+
python examples/demo.py
|
|
223
|
+
python examples/demo_fame.py
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
## License
|
|
227
|
+
|
|
228
|
+
MIT — see [LICENSE](LICENSE).
|
plotlibs-0.3.0/README.md
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="assets/banner.svg" alt="plotlibs banner" width="100%"/>
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<p align="center">
|
|
6
|
+
<img src="assets/logo.svg" alt="plotlibs logo" width="96"/>
|
|
7
|
+
</p>
|
|
8
|
+
|
|
9
|
+
<h1 align="center">plotlibs</h1>
|
|
10
|
+
<p align="center"><b>Fast, beautiful Python plotting for everyone.</b></p>
|
|
11
|
+
|
|
12
|
+
<p align="center">
|
|
13
|
+
<a href="https://github.com/salim-studio/plotlibs"><img src="https://img.shields.io/badge/github-salim--studio%2Fplotlibs-0F172A?logo=github" alt="GitHub"/></a>
|
|
14
|
+
<img src="https://img.shields.io/badge/version-0.3.0-4F46E5" alt="version"/>
|
|
15
|
+
<img src="https://img.shields.io/badge/speed-~4x_vs_matplotlib-06B6D4" alt="speed"/>
|
|
16
|
+
<img src="https://img.shields.io/badge/deps-numpy_%2B_pillow_only-A3E635" alt="deps"/>
|
|
17
|
+
<img src="https://img.shields.io/badge/license-MIT-FACC15" alt="license"/>
|
|
18
|
+
<img src="https://img.shields.io/badge/python-%3E%3D3.9-3776AB?logo=python&logoColor=white" alt="python"/>
|
|
19
|
+
</p>
|
|
20
|
+
|
|
21
|
+
> **Renamed:** `plotlib` → **`plotlibs`**.
|
|
22
|
+
> Old code keeps working via a shim (`import plotlib`), but please migrate to `import plotlibs`.
|
|
23
|
+
> New home: **https://github.com/salim-studio/plotlibs**
|
|
24
|
+
|
|
25
|
+
```python
|
|
26
|
+
import plotlibs as pl
|
|
27
|
+
|
|
28
|
+
pl.plot([1, 2, 3], [1, 4, 9], label="x²")
|
|
29
|
+
pl.xlabel("x"); pl.ylabel("y"); pl.legend()
|
|
30
|
+
pl.savefig("out.png") # or pl.show()
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Why plotlibs?
|
|
34
|
+
|
|
35
|
+
| Audience | One-liner value |
|
|
36
|
+
|---|---|
|
|
37
|
+
| Developers | Matplotlib-compatible API, only `numpy + pillow`, ~4x faster on big data |
|
|
38
|
+
| Data analysts | `pl.load_csv` → `pl.quick_eda(df)` → `boxplot / kde / heatmap / countplot` |
|
|
39
|
+
| Databases | `pl.db_connect("sales.db")` + `pl.read_sql(...)` + `plot_from_sql(...)` (sqlite / SQLAlchemy / DuckDB) |
|
|
40
|
+
| Machine learning | `plot_confusion_matrix`, `plot_roc`, `plot_pr`, `feature_importance`, `residuals`, `elbow` |
|
|
41
|
+
| Deep learning | `plot_history`, `plot_images`, `plot_clusters_2d` |
|
|
42
|
+
|
|
43
|
+
## Install
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
pip install plotlibs # minimal: numpy + pillow
|
|
47
|
+
pip install "plotlibs[all]" # pandas + sqlalchemy + duckdb + sklearn + matplotlib
|
|
48
|
+
pip install -e ".[dev]" # contributors
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## 30-second tour
|
|
52
|
+
|
|
53
|
+
```python
|
|
54
|
+
import plotlibs as pl
|
|
55
|
+
|
|
56
|
+
# 1) EDA in one line
|
|
57
|
+
df = pl.load_csv("sales.csv")
|
|
58
|
+
print(pl.describe(df))
|
|
59
|
+
pl.quick_eda(df)
|
|
60
|
+
|
|
61
|
+
# 2) Stats plots (all matplotlib-style signatures)
|
|
62
|
+
pl.boxplot([[1, 2, 3], [2, 3, 4]], labels=["A", "B"])
|
|
63
|
+
pl.violinplot([[1, 2, 3], [2, 3, 4]])
|
|
64
|
+
pl.kde(df["sales"])
|
|
65
|
+
pl.heatmap([[1, 0.8], [0.8, 1]], annot=True)
|
|
66
|
+
pl.corr(df, annot=True)
|
|
67
|
+
pl.countplot(["Cairo", "Oran", "Cairo"])
|
|
68
|
+
pl.area([1, 2, 3], [1, 1, 1], [2, 2, 2], labels=["a", "b"])
|
|
69
|
+
pl.hist2d([1, 2, 2, 3], [1, 1, 2, 2])
|
|
70
|
+
pl.stem([1, 2, 3], [2, 1, 3])
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
```python
|
|
74
|
+
# 3) SQL -> plot
|
|
75
|
+
conn = pl.db_connect("sales.db") # or ":memory:", "sqlite:///x.db", "duckdb://shop.ddb"
|
|
76
|
+
pl.to_sql(df, "sales", conn)
|
|
77
|
+
print(pl.db.list_tables(conn))
|
|
78
|
+
df2 = pl.read_sql("SELECT region, SUM(amount) FROM sales GROUP BY region", conn)
|
|
79
|
+
pl.db.plot_from_sql("SELECT qty, amount FROM sales LIMIT 500", conn, kind="scatter")
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
```python
|
|
83
|
+
# 4) ML / DL
|
|
84
|
+
pl.plot_history({"loss": [0.9, 0.5, 0.3], "val_loss": [1.0, 0.6, 0.4]})
|
|
85
|
+
pl.plot_confusion_matrix(y_true, y_pred, normalize=True)
|
|
86
|
+
pl.plot_roc(y_true, y_score, label="xgb")
|
|
87
|
+
pl.plot_feature_importance(["age", "salary", "city"], [0.5, 0.3, 0.2])
|
|
88
|
+
pl.plot_images(mnist_images)
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Visual identity
|
|
92
|
+
|
|
93
|
+
Brand: **midnight ink `#0F172A` + indigo `#4F46E5` + cyan `#06B6D4`**, highlights lime `#A3E635` / amber `#FACC15`, background paper `#F8FAFC`. Logo: rounded-square gradient with a white line chart. See [`assets/`](assets/) and [`BRANDING.md`](BRANDING.md).
|
|
94
|
+
|
|
95
|
+
Signature theme:
|
|
96
|
+
|
|
97
|
+
```python
|
|
98
|
+
import plotlibs as pl
|
|
99
|
+
pl.style.use("plotlibs") # light signature
|
|
100
|
+
pl.style.use("plotlibs-dark") # dark signature
|
|
101
|
+
print(pl.style.available())
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
| Token | Hex | Use |
|
|
105
|
+
|---|---|---|
|
|
106
|
+
| primary | `#4F46E5` | lines, logo start, links |
|
|
107
|
+
| accent | `#06B6D4` | second series, banner end |
|
|
108
|
+
| ink | `#0F172A` | text, dark backgrounds |
|
|
109
|
+
| paper | `#F8FAFC` | page background |
|
|
110
|
+
| lime | `#A3E635` | highlight dots |
|
|
111
|
+
| amber | `#FACC15` | highlight dots |
|
|
112
|
+
|
|
113
|
+
## Matplotlib compatibility
|
|
114
|
+
|
|
115
|
+
| matplotlib | plotlibs 0.3.0 |
|
|
116
|
+
|---|---|
|
|
117
|
+
| `plot / scatter / bar / hist / imshow / pie / fill_between / step / errorbar` | ✅ same signature |
|
|
118
|
+
| `boxplot / violinplot / hist2d / stem / stackplot` | ✅ |
|
|
119
|
+
| `xlabel / ylabel / title / legend / grid / xlim / ylim / savefig / show / subplots` | ✅ |
|
|
120
|
+
| `style.use / rcParams` | ✅ + `plotlibs`, `plotlibs-dark`, `seaborn`, `plotly`, `publication` |
|
|
121
|
+
|
|
122
|
+
## Why faster?
|
|
123
|
+
|
|
124
|
+
1. **Min-max decimation** — lines over 2000 points are bucketed (min+max preserved), `O(n)` in numpy.
|
|
125
|
+
2. **Pillow rasterizer** — direct C-level drawing, no heavy layout engine.
|
|
126
|
+
3. **Vectorized pipeline** — data→pixel in one pass, numpy ticks/limits.
|
|
127
|
+
4. **No heavy objects** — artists are plain dicts, render is deferred.
|
|
128
|
+
|
|
129
|
+
Benchmark (`n=200k`, `benchmarks/bench.py`):
|
|
130
|
+
|
|
131
|
+
```
|
|
132
|
+
plotlibs : ~370 ms/plot
|
|
133
|
+
matplotlib : ~1560 ms/plot
|
|
134
|
+
speedup : ~4.2x faster
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
## Project layout
|
|
138
|
+
|
|
139
|
+
```
|
|
140
|
+
plotlibs/ # repo root (package name == repo name)
|
|
141
|
+
plotlibs/ # real package
|
|
142
|
+
__init__.py pyplot.py figure.py colors.py fast.py style.py
|
|
143
|
+
data.py db.py eda.py ml.py
|
|
144
|
+
backends/renderer.py
|
|
145
|
+
plotlib/ # deprecated shim (renamed alias)
|
|
146
|
+
assets/ # logo.svg, banner.svg
|
|
147
|
+
tests/ benchmarks/ examples/
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
## Migration from `plotlib`
|
|
151
|
+
|
|
152
|
+
```diff
|
|
153
|
+
- import plotlib as pl
|
|
154
|
+
+ import plotlibs as pl
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
`import plotlib` still works in 0.3.x (emits `DeprecationWarning`) and will be removed in 1.0.
|
|
158
|
+
|
|
159
|
+
## Roadmap
|
|
160
|
+
|
|
161
|
+
- [x] 0.3.0 — Rename to **plotlibs**, English docs, brand identity (this release)
|
|
162
|
+
- [ ] 0.4.0 — Interactive HTML export (`pl.save_html`), dashboards, RTL/Arabic labels
|
|
163
|
+
- [ ] 0.5.0 — Geo + time-series + sklearn/HF pipeline helpers
|
|
164
|
+
- Suggest ideas: open an issue with `[idea]` at https://github.com/salim-studio/plotlibs/issues
|
|
165
|
+
|
|
166
|
+
## Contributing
|
|
167
|
+
|
|
168
|
+
```bash
|
|
169
|
+
python -m pytest tests -q
|
|
170
|
+
python examples/demo.py
|
|
171
|
+
python examples/demo_fame.py
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
## License
|
|
175
|
+
|
|
176
|
+
MIT — see [LICENSE](LICENSE).
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"""Deprecated alias: ``import plotlib`` now maps to ``plotlibs``.
|
|
2
|
+
|
|
3
|
+
The library was renamed from ``plotlib`` to ``plotlibs`` (see
|
|
4
|
+
https://github.com/salim-studio/plotlibs). This shim keeps old code working.
|
|
5
|
+
Please migrate::
|
|
6
|
+
|
|
7
|
+
# old
|
|
8
|
+
import plotlib as pl
|
|
9
|
+
# new
|
|
10
|
+
import plotlibs as pl
|
|
11
|
+
"""
|
|
12
|
+
from __future__ import annotations
|
|
13
|
+
|
|
14
|
+
import warnings
|
|
15
|
+
|
|
16
|
+
warnings.warn(
|
|
17
|
+
"The package was renamed 'plotlib' -> 'plotlibs'. "
|
|
18
|
+
"Please use 'import plotlibs as pl'. The 'plotlib' alias will be removed in 1.0.",
|
|
19
|
+
DeprecationWarning,
|
|
20
|
+
stacklevel=2,
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
from plotlibs import * # noqa: F401,F403
|
|
24
|
+
from plotlibs import ( # noqa: F401
|
|
25
|
+
Figure, figure, subplots, plt, pyplot, style, rcParams,
|
|
26
|
+
data, db, eda, ml,
|
|
27
|
+
plot, scatter, bar, barh, hist, imshow, pie, fill_between,
|
|
28
|
+
step, errorbar, axhline, axvline, boxplot, violinplot, kde, density,
|
|
29
|
+
heatmap, corr, countplot, area, stackplot, hist2d, stem,
|
|
30
|
+
xlabel, ylabel, title, legend, grid, xlim, ylim,
|
|
31
|
+
savefig, show, close, gca, gcf,
|
|
32
|
+
load_csv, save_csv, describe, db_connect, read_sql, to_sql,
|
|
33
|
+
quick_eda, scatter_matrix, plot_missing,
|
|
34
|
+
plot_history, plot_confusion_matrix, plot_roc, plot_pr,
|
|
35
|
+
plot_feature_importance, figure_to_image,
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
__version__ = "0.3.0"
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"""plotlibs — fast, beautiful Python plotting for everyone.
|
|
2
|
+
|
|
3
|
+
Drop-in matplotlib alternative (4x faster), plus one-liners for
|
|
4
|
+
DataFrames, SQL databases, EDA, machine learning and deep learning.
|
|
5
|
+
|
|
6
|
+
import plotlibs as pl
|
|
7
|
+
pl.plot([1, 2, 3], [1, 4, 9], label="x^2")
|
|
8
|
+
pl.xlabel("x"); pl.ylabel("y"); pl.legend(); pl.savefig("out.png")
|
|
9
|
+
|
|
10
|
+
# Data analysts:
|
|
11
|
+
df = pl.load_csv("sales.csv")
|
|
12
|
+
pl.quick_eda(df)
|
|
13
|
+
|
|
14
|
+
# Databases:
|
|
15
|
+
conn = pl.db_connect("sales.db")
|
|
16
|
+
df2 = pl.read_sql("SELECT * FROM sales", conn)
|
|
17
|
+
|
|
18
|
+
# ML / DL:
|
|
19
|
+
pl.plot_history({"loss": [...], "val_loss": [...]})
|
|
20
|
+
pl.plot_confusion_matrix(y_true, y_pred)
|
|
21
|
+
"""
|
|
22
|
+
from __future__ import annotations
|
|
23
|
+
|
|
24
|
+
from . import pyplot as plt
|
|
25
|
+
from .figure import Figure, figure, subplots
|
|
26
|
+
from . import style
|
|
27
|
+
from .style import rcParams
|
|
28
|
+
|
|
29
|
+
# Data + databases + EDA + ML
|
|
30
|
+
from . import data as data
|
|
31
|
+
from . import db as db
|
|
32
|
+
from . import eda as eda
|
|
33
|
+
from . import ml as ml
|
|
34
|
+
|
|
35
|
+
__version__ = "0.3.0"
|
|
36
|
+
__brand__ = "plotlibs"
|
|
37
|
+
__all__ = ["Figure", "figure", "subplots", "plt", "pyplot", "style", "rcParams",
|
|
38
|
+
"data", "db", "eda", "ml",
|
|
39
|
+
"plot", "scatter", "bar", "barh", "hist", "imshow", "pie",
|
|
40
|
+
"fill_between", "boxplot", "violinplot", "kde", "heatmap",
|
|
41
|
+
"corr", "countplot", "area", "hist2d", "stem",
|
|
42
|
+
"savefig", "show", "figure_to_image",
|
|
43
|
+
"load_csv", "read_sql", "db_connect", "quick_eda",
|
|
44
|
+
"plot_history", "plot_confusion_matrix", "plot_roc"]
|
|
45
|
+
|
|
46
|
+
from . import pyplot as pyplot # noqa: E402
|
|
47
|
+
|
|
48
|
+
plot = pyplot.plot
|
|
49
|
+
scatter = pyplot.scatter
|
|
50
|
+
bar = pyplot.bar
|
|
51
|
+
barh = pyplot.barh
|
|
52
|
+
hist = pyplot.hist
|
|
53
|
+
imshow = pyplot.imshow
|
|
54
|
+
pie = pyplot.pie
|
|
55
|
+
fill_between = pyplot.fill_between
|
|
56
|
+
step = pyplot.step
|
|
57
|
+
errorbar = pyplot.errorbar
|
|
58
|
+
axhline = pyplot.axhline
|
|
59
|
+
axvline = pyplot.axvline
|
|
60
|
+
boxplot = pyplot.boxplot
|
|
61
|
+
violinplot = pyplot.violinplot
|
|
62
|
+
kde = pyplot.kde
|
|
63
|
+
density = pyplot.kde
|
|
64
|
+
heatmap = pyplot.heatmap
|
|
65
|
+
corr = pyplot.corr
|
|
66
|
+
countplot = pyplot.countplot
|
|
67
|
+
area = pyplot.area
|
|
68
|
+
stackplot = pyplot.area
|
|
69
|
+
hist2d = pyplot.hist2d
|
|
70
|
+
stem = pyplot.stem
|
|
71
|
+
xlabel = pyplot.xlabel
|
|
72
|
+
ylabel = pyplot.ylabel
|
|
73
|
+
title = pyplot.title
|
|
74
|
+
legend = pyplot.legend
|
|
75
|
+
grid = pyplot.grid
|
|
76
|
+
xlim = pyplot.xlim
|
|
77
|
+
ylim = pyplot.ylim
|
|
78
|
+
savefig = pyplot.savefig
|
|
79
|
+
show = pyplot.show
|
|
80
|
+
close = pyplot.close
|
|
81
|
+
gca = pyplot.gca
|
|
82
|
+
gcf = pyplot.gcf
|
|
83
|
+
figure_fn = figure
|
|
84
|
+
subplots = subplots
|
|
85
|
+
|
|
86
|
+
# --- data / DB shortcuts ---
|
|
87
|
+
load_csv = data.load_csv
|
|
88
|
+
save_csv = data.save_csv
|
|
89
|
+
describe = data.describe
|
|
90
|
+
|
|
91
|
+
db_connect = db.connect
|
|
92
|
+
read_sql = db.read_sql
|
|
93
|
+
to_sql = db.to_sql
|
|
94
|
+
|
|
95
|
+
# --- EDA shortcuts ---
|
|
96
|
+
quick_eda = eda.quick_eda
|
|
97
|
+
scatter_matrix = eda.scatter_matrix
|
|
98
|
+
plot_missing = eda.plot_missing
|
|
99
|
+
|
|
100
|
+
# --- ML/DL shortcuts ---
|
|
101
|
+
plot_history = ml.plot_history
|
|
102
|
+
plot_confusion_matrix = ml.plot_confusion_matrix
|
|
103
|
+
plot_roc = ml.plot_roc
|
|
104
|
+
plot_pr = ml.plot_pr
|
|
105
|
+
plot_feature_importance = ml.plot_feature_importance
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
def figure_to_image(fig=None):
|
|
109
|
+
from .backends.renderer import render_to_image
|
|
110
|
+
return render_to_image(fig or pyplot.gcf())
|
|
File without changes
|