termatplotlib 0.1.0__tar.gz → 0.6.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.
Files changed (46) hide show
  1. {termatplotlib-0.1.0 → termatplotlib-0.6.0}/LICENSE +1 -1
  2. termatplotlib-0.6.0/PKG-INFO +412 -0
  3. termatplotlib-0.6.0/README.md +395 -0
  4. termatplotlib-0.6.0/pyproject.toml +36 -0
  5. termatplotlib-0.6.0/termatplotlib/__init__.py +61 -0
  6. termatplotlib-0.6.0/termatplotlib/bar.py +197 -0
  7. termatplotlib-0.6.0/termatplotlib/boxplot.py +142 -0
  8. termatplotlib-0.6.0/termatplotlib/bubble.py +129 -0
  9. termatplotlib-0.6.0/termatplotlib/bullet.py +74 -0
  10. termatplotlib-0.6.0/termatplotlib/calendar_heatmap.py +82 -0
  11. termatplotlib-0.6.0/termatplotlib/candlestick.py +79 -0
  12. termatplotlib-0.6.0/termatplotlib/cli.py +129 -0
  13. termatplotlib-0.6.0/termatplotlib/diverging_bar.py +71 -0
  14. termatplotlib-0.6.0/termatplotlib/donut.py +102 -0
  15. termatplotlib-0.6.0/termatplotlib/figure.py +35 -0
  16. termatplotlib-0.6.0/termatplotlib/funnel.py +63 -0
  17. termatplotlib-0.6.0/termatplotlib/gantt.py +78 -0
  18. termatplotlib-0.6.0/termatplotlib/heatmap.py +93 -0
  19. termatplotlib-0.6.0/termatplotlib/hist.py +100 -0
  20. termatplotlib-0.6.0/termatplotlib/line.py +341 -0
  21. termatplotlib-0.6.0/termatplotlib/pareto.py +97 -0
  22. termatplotlib-0.6.0/termatplotlib/pie.py +59 -0
  23. termatplotlib-0.6.0/termatplotlib/radar.py +169 -0
  24. termatplotlib-0.6.0/termatplotlib/sankey.py +127 -0
  25. termatplotlib-0.6.0/termatplotlib/scatter.py +135 -0
  26. termatplotlib-0.6.0/termatplotlib/sparkline.py +53 -0
  27. termatplotlib-0.6.0/termatplotlib/step.py +133 -0
  28. termatplotlib-0.6.0/termatplotlib/strip.py +70 -0
  29. termatplotlib-0.6.0/termatplotlib/utils.py +268 -0
  30. termatplotlib-0.6.0/termatplotlib/vertical_bar.py +67 -0
  31. termatplotlib-0.6.0/termatplotlib/violin.py +102 -0
  32. termatplotlib-0.6.0/termatplotlib/waterfall.py +140 -0
  33. termatplotlib-0.6.0/termatplotlib/wordcloud.py +93 -0
  34. termatplotlib-0.6.0/termatplotlib.egg-info/PKG-INFO +412 -0
  35. termatplotlib-0.6.0/termatplotlib.egg-info/SOURCES.txt +38 -0
  36. termatplotlib-0.6.0/termatplotlib.egg-info/entry_points.txt +2 -0
  37. termatplotlib-0.6.0/tests/test_termatplotlib.py +1054 -0
  38. termatplotlib-0.1.0/PKG-INFO +0 -139
  39. termatplotlib-0.1.0/README.md +0 -116
  40. termatplotlib-0.1.0/setup.py +0 -19
  41. termatplotlib-0.1.0/termatplotlib/__init__.py +0 -370
  42. termatplotlib-0.1.0/termatplotlib.egg-info/PKG-INFO +0 -139
  43. termatplotlib-0.1.0/termatplotlib.egg-info/SOURCES.txt +0 -8
  44. {termatplotlib-0.1.0 → termatplotlib-0.6.0}/setup.cfg +0 -0
  45. {termatplotlib-0.1.0 → termatplotlib-0.6.0}/termatplotlib.egg-info/dependency_links.txt +0 -0
  46. {termatplotlib-0.1.0 → termatplotlib-0.6.0}/termatplotlib.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2025 RK RIAD & RK STUDIO 585
3
+ Copyright (c) 2025 RK Riad Khan
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -0,0 +1,412 @@
1
+ Metadata-Version: 2.4
2
+ Name: termatplotlib
3
+ Version: 0.6.0
4
+ Summary: A lightweight and elegant Python library for rendering stunning ASCII plots directly in your terminal.
5
+ Author-email: RK Riad Khan <rkriad585@gmail.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/rkriad585/termatplotlib
8
+ Keywords: ascii,terminal,plot,chart,visualization
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Operating System :: OS Independent
12
+ Classifier: Programming Language :: Python :: 3 :: Only
13
+ Requires-Python: >=3.6
14
+ Description-Content-Type: text/markdown
15
+ License-File: LICENSE
16
+ Dynamic: license-file
17
+
18
+ # termatplotlib
19
+
20
+ A lightweight and elegant Python library for rendering stunning ASCII plots directly in your terminal. Zero dependencies.
21
+
22
+ ## Features
23
+
24
+ - **28 Chart Types** — Bar, grouped bar, stacked bar, diverging bar, vertical bar, scatter, line, pie, histogram, area, box plot, violin plot, heatmap, calendar heatmap, candlestick, sparkline, radar, waterfall, gantt, step chart, bubble chart, strip plot, sankey, funnel, bullet, donut, pareto, wordcloud.
25
+ - **Logarithmic Axes** — `log_x` / `log_y` for scatter, line, and area charts.
26
+ - **Error Bars** — `error_y` for bar, scatter, and line charts.
27
+ - **Threshold Lines** — Horizontal/vertical reference lines on scatter/line charts.
28
+ - **Custom Ticks & Formatters** — `custom_xticks`, `custom_yticks`, `tick_formatter` for full axis control.
29
+ - **Theme Presets** — 7 built-in themes (default, dark, light, monokai, ocean, forest, sunset).
30
+ - **Multi-Figure Layout** — `Figure` class to compose multiple charts together.
31
+ - **Configuration System** — `set_default()` / `get_default()` / `reset_defaults()` for global styling.
32
+ - **CLI Tool** — Pipe data from stdin directly into charts via `termtplotlib` command.
33
+ - **Customization** — Titles, axis labels, colors, markers, legends, axis limits, grid lines.
34
+ - **File Output** — Save plots to text files (ANSI codes automatically stripped).
35
+ - **Terminal Auto-Detect** — Automatically fits to your terminal width.
36
+ - **Multi-Series** — Plot multiple data series on the same chart.
37
+ - **No Dependencies** — Pure Python, no external packages required.
38
+
39
+ ## Installation
40
+
41
+ ```bash
42
+ pip install termatplotlib
43
+ ```
44
+
45
+ Or from source:
46
+
47
+ ```bash
48
+ git clone https://github.com/rkriad585/termatplotlib
49
+ cd termatplotlib
50
+ pip install .
51
+ ```
52
+
53
+ ## Quick Start
54
+
55
+ ```python
56
+ import termatplotlib as tpl
57
+
58
+ # Bar chart
59
+ tpl.bar(["A", "B", "C", "D"], [10, 20, 15, 5],
60
+ title="My Chart", xlabel="Value", color="red")
61
+ ```
62
+
63
+ ## Chart Types
64
+
65
+ ### Bar Chart
66
+ ```python
67
+ tpl.bar(labels, values, title=None, xlabel=None, ylabel=None,
68
+ color=None, max_width=None, output_file=None, error_y=None)
69
+ ```
70
+
71
+ ### Grouped Bar Chart
72
+ ```python
73
+ tpl.grouped_bar(labels, values, title=None, xlabel=None, ylabel=None,
74
+ colors=None, max_width=None, output_file=None)
75
+ ```
76
+
77
+ ### Stacked Bar Chart
78
+ ```python
79
+ tpl.stacked_bar(labels, values, title=None, xlabel=None, ylabel=None,
80
+ colors=None, max_width=None, output_file=None)
81
+ ```
82
+
83
+ ### Scatter Plot
84
+ ```python
85
+ data = [
86
+ {'x': [1, 2, 3], 'y': [4, 5, 6], 'color': 'red', 'marker': 'o',
87
+ 'label': 'Series 1', 'error_y': 0.5},
88
+ ]
89
+ tpl.scatter(data, title="My Plot", xlabel="X", ylabel="Y",
90
+ legend=True, grid=True, log_y=True, output_file="plot.txt")
91
+ ```
92
+
93
+ ### Line Chart
94
+ ```python
95
+ data = [
96
+ {'x': [0, 1, 2], 'y': [0, 1, 4], 'color': 'green',
97
+ 'marker': '*', 'label': 'Quadratic', 'error_y': 0.2},
98
+ ]
99
+ tpl.line(data, title="Line Plot", width=50, height=20, legend=True, grid=True)
100
+ ```
101
+
102
+ ### Area Chart
103
+ ```python
104
+ tpl.area(data, title="Area Under Curve", stacked=False, legend=True, log_y=True)
105
+ ```
106
+
107
+ ### Pie Chart
108
+ ```python
109
+ tpl.pie(labels, values, title="My Pie", radius=10, legend=True)
110
+ ```
111
+
112
+ ### Histogram
113
+ ```python
114
+ tpl.hist(data, bins=10, title="Histogram", xlabel="Value", ylabel="Frequency",
115
+ color="magenta", width=None, height=10)
116
+ ```
117
+
118
+ ### Box Plot
119
+ ```python
120
+ tpl.boxplot(data, labels=["Group A", "Group B"], title="Comparison",
121
+ color="cyan", width=50, height=20)
122
+ ```
123
+
124
+ ### Heatmap
125
+ ```python
126
+ data = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
127
+ tpl.heatmap(data, row_labels=["A", "B", "C"], col_labels=["X", "Y", "Z"],
128
+ title="Heatmap", color="red")
129
+ ```
130
+
131
+ ### Vertical Bar Chart
132
+ ```python
133
+ tpl.vertical_bar(["A", "B", "C"], [10, 20, 15], height=15, title="Vertical")
134
+ ```
135
+
136
+ ### Diverging Bar Chart
137
+ ```python
138
+ tpl.diverging_bar(["Profit", "Loss"], [100, -30], baseline=0, colors=["green", "red"])
139
+ ```
140
+
141
+ ### Sparkline (inline mini-chart)
142
+ ```python
143
+ tpl.sparkline([1, 5, 22, 13, 5], title="Trend", color="green")
144
+ ```
145
+
146
+ ### Candlestick Chart (OHLC)
147
+ ```python
148
+ data = [
149
+ {'open': 100, 'high': 110, 'low': 95, 'close': 105},
150
+ {'open': 105, 'high': 115, 'low': 100, 'close': 102},
151
+ ]
152
+ tpl.candlestick(data, width=40, height=15, title="AAPL")
153
+ ```
154
+
155
+ ### Violin Plot
156
+ ```python
157
+ tpl.violinplot([[1, 2, 3, 4, 5], [2, 3, 4, 5, 6]],
158
+ labels=["A", "B"], title="Distribution")
159
+ ```
160
+
161
+ ### Calendar Heatmap
162
+ ```python
163
+ tpl.calendar_heatmap({"2026-01-01": 5, "2026-06-15": 10}, title="Activity")
164
+ ```
165
+
166
+ ### Radar Chart
167
+ ```python
168
+ tpl.radar(["Speed", "Power", "Agility", "Stamina", "Intelligence"],
169
+ [8, 6, 9, 5, 7], width=30, title="Attributes", fill=True, color="red")
170
+ ```
171
+
172
+ ### Waterfall Chart
173
+ ```python
174
+ tpl.waterfall(["Revenue", "Costs", "Tax", "Net Profit"],
175
+ [1000, -300, -100, 600], width=60, title="P&L Bridge")
176
+ ```
177
+
178
+ ### Gantt Chart
179
+ ```python
180
+ tasks = [
181
+ {'label': 'Research', 'start': 0, 'end': 5},
182
+ {'label': 'Design', 'start': 3, 'end': 8},
183
+ {'label': 'Dev', 'start': 6, 'end': 12},
184
+ {'label': 'Test', 'start': 10, 'end': 14},
185
+ ]
186
+ tpl.gantt(tasks, width=60, title="Project Timeline")
187
+ ```
188
+
189
+ ### Step Chart
190
+ ```python
191
+ tpl.step([{'x': [0, 1, 2, 3], 'y': [0, 1, 1, 4]}],
192
+ width=40, height=15, title="Step", grid=True, legend=True)
193
+ ```
194
+
195
+ ### Bubble Chart
196
+ ```python
197
+ tpl.bubble([{'x': [1, 2, 3, 4], 'y': [10, 20, 15, 30],
198
+ 'size': [2, 8, 4, 12], 'label': 'Products'}],
199
+ width=40, height=15, title="Bubble Chart", legend=True)
200
+ ```
201
+
202
+ ### Strip Plot
203
+ ```python
204
+ tpl.strip([1, 2, 2, 3, 3, 3, 4, 5, 6], width=40, title="Distribution", color="cyan")
205
+ ```
206
+
207
+ ### Sankey Diagram
208
+ ```python
209
+ nodes = ["Revenue", "Costs", "Tax", "Profit"]
210
+ links = [
211
+ {"source": "Revenue", "target": "Costs", "value": 400},
212
+ {"source": "Revenue", "target": "Tax", "value": 200},
213
+ {"source": "Revenue", "target": "Profit", "value": 400},
214
+ ]
215
+ tpl.sankey(nodes, links, width=60, title="Cash Flow")
216
+ ```
217
+
218
+ ### Funnel Chart
219
+ ```python
220
+ tpl.funnel(["Awareness", "Interest", "Desire", "Action"],
221
+ [1000, 500, 200, 50], width=50, title="Sales Pipeline", color="cyan")
222
+ ```
223
+
224
+ ### Bullet Chart (KPI Gauge)
225
+ ```python
226
+ tpl.bullet(["Revenue", "Users", "Satisfaction"],
227
+ [85, 70, 90], [100, 80, 95], width=60, title="Dashboard")
228
+ ```
229
+
230
+ ### Donut Chart
231
+ ```python
232
+ tpl.donut(["Product", "Service", "Subscription", "Other"],
233
+ [40, 30, 20, 10], title="Revenue Mix", legend=True, center_label="Total")
234
+ ```
235
+
236
+ ### Pareto Chart
237
+ ```python
238
+ tpl.pareto(["Issue A", "Issue B", "Issue C", "Issue D"],
239
+ [50, 30, 15, 5], width=60, title="Bug Priority", show_80_line=True)
240
+ ```
241
+
242
+ ### Word Cloud
243
+ ```python
244
+ tpl.wordcloud({"python": 10, "data": 8, "chart": 5, "terminal": 4,
245
+ "ascii": 3, "visualization": 3, "library": 2},
246
+ width=50, title="Tag Cloud")
247
+ ```
248
+
249
+ ### Figure (Multi-Chart Layout)
250
+ ```python
251
+ fig = tpl.Figure(title="Dashboard")
252
+ fig.add_chart(tpl.bar, ["A", "B"], [10, 20], max_width=40, color="red")
253
+ fig.add_chart(tpl.pie, ["X", "Y"], [30, 70])
254
+ fig.render()
255
+ fig.savefig("dashboard.txt")
256
+ ```
257
+
258
+ ### Threshold Lines
259
+ ```python
260
+ tpl.scatter([{'x': [1, 2, 3], 'y': [4, 5, 6]}],
261
+ thresholds=[{'axis': 'y', 'value': 5, 'color': 'red'}])
262
+ ```
263
+
264
+ ### Custom Ticks & Formatters
265
+ ```python
266
+ tpl.scatter([{'x': [1, 2, 3], 'y': [4, 5, 6]}],
267
+ custom_xticks=[1, 2, 3],
268
+ tick_formatter=lambda v: f"${v:.0f}")
269
+ ```
270
+
271
+ ### Themes
272
+ ```python
273
+ tpl.apply_theme('monokai')
274
+ tpl.bar(["A", "B"], [10, 20])
275
+ ```
276
+
277
+ ### CLI (stdin pipeline)
278
+ ```bash
279
+ echo "1,5,22,13,5" | termatplotlib --type sparkline --color green
280
+ echo "10,20,15,30,25" | termatplotlib --type bar --labels "A B C D E" --title "Data"
281
+ ```
282
+
283
+ ## Parameters
284
+
285
+ | Parameter | Used By | Description |
286
+ |-----------|---------|-------------|
287
+ | `title` | All | Chart title centered at top |
288
+ | `color` | bar, scatter, line, hist, boxplot, heatmap, sparkline, radar, strip, funnel | Chart color (named) |
289
+ | `colors` | grouped_bar, stacked_bar, diverging_bar, sankey, wordcloud | List of colors per series |
290
+ | `colors_list` | radar | List of axis colors |
291
+ | `output_file` | All | Save to file (no ANSI codes) |
292
+ | `legend` | scatter, line, area, pie, step, bubble, donut | Show data legend |
293
+ | `width` | scatter, line, area, boxplot, heatmap, vertical_bar, radar, bubble, gantt, sankey, funnel, bullet, pareto, wordcloud | Plot width in chars |
294
+ | `height` | scatter, line, area, hist, boxplot, vertical_bar, violin, candlestick, bubble, strip, pareto, wordcloud | Plot height in chars |
295
+ | `max_width` | bar, grouped_bar, stacked_bar, diverging_bar, waterfall | Max chart width |
296
+ | `bins` | hist | Number of histogram bins |
297
+ | `marker` | scatter, line, area, bubble (per series) | Point marker character |
298
+ | `stacked` | area | Stack series on top of each other |
299
+ | `log_x`, `log_y` | scatter, line, area | Logarithmic axes |
300
+ | `error_y` | bar (function param), scatter, line (per series) | Error bar magnitude |
301
+ | `grid` | scatter, line, area, step | Show grid lines |
302
+ | `xlim`, `ylim` | scatter, line, area, step | Custom axis limits |
303
+ | `thresholds` | scatter, line, step | Reference lines `[{axis, value, color, char}]` |
304
+ | `custom_xticks`, `custom_yticks` | scatter, line, area | Explicit tick positions |
305
+ | `tick_formatter` | scatter, line, area | Custom tick label formatter |
306
+ | `palette` | heatmap, calendar_heatmap | List of colors for data range |
307
+ | `baseline` | diverging_bar | Center value for divergence |
308
+ | `color_up`, `color_down`, `color_total` | candlestick, waterfall | Directional colors |
309
+ | `fill` | radar | Fill polygon interior |
310
+ | `scale_max` | radar | Fixed scale maximum |
311
+ | `bar_char` | gantt | Character for bar drawing |
312
+ | `jitter` | strip | Stack dots in columns |
313
+ | `show_percent` | funnel | Show % of first stage |
314
+ | `color_actual`, `color_target` | bullet | Actual vs target colors |
315
+ | `center_label` | donut | Text in center hole |
316
+ | `show_80_line` | pareto | Show 80% reference line |
317
+
318
+ ## Configuration System
319
+
320
+ ```python
321
+ tpl.apply_theme('monokai') # apply built-in theme
322
+ tpl.set_default(width=80, height=30, color='blue', legend=True)
323
+ tpl.get_default('color') # 'blue'
324
+ tpl.reset_defaults() # clear all defaults
325
+ ```
326
+
327
+ ## Themes
328
+
329
+ `default`, `dark`, `light`, `monokai`, `ocean`, `forest`, `sunset`
330
+
331
+ ## Colors
332
+
333
+ `black`, `red`, `green`, `yellow`, `blue`, `magenta`, `cyan`, `white`
334
+
335
+ ## Markers
336
+
337
+ Any single character. Common choices: `'o'`, `'x'`, `'*'`, `'.'`, `'+'`, `'#'`
338
+
339
+ ## CLI Examples
340
+
341
+ ```bash
342
+ # Bar chart from stdin
343
+ echo "10,20,15,30" | termatplotlib --type bar --labels "A B C D" --title "Sales" --color blue
344
+
345
+ # Sparkline from stdin
346
+ echo "1,5,22,13,5,8,3,10" | termatplotlib --type sparkline --color green
347
+
348
+ # Histogram from stdin
349
+ echo "1 2 2 3 3 3 4 5 5 6" | termatplotlib --type hist --bins 5 --title "Distribution"
350
+
351
+ # Step chart from stdin
352
+ seq 1 10 | termatplotlib --type step --title "Step" --grid
353
+
354
+ # Strip plot from stdin
355
+ echo "1 1 1 2 2 3 3 3 3 4 5 5 6" | termatplotlib --type strip --color cyan
356
+
357
+ # Radar chart from stdin
358
+ echo "8 6 9 5 7" | termatplotlib --type radar --labels "Speed Power Agility Stamina Intel" --color red
359
+
360
+ # Funnel chart from stdin
361
+ echo "1000 500 200 50" | termatplotlib --type funnel --labels "Aware Interest Desire Action" --color cyan
362
+
363
+ # Pareto chart from stdin
364
+ echo "50 30 15 5" | termatplotlib --type pareto --labels "A B C D" --width 60 --title "Priority"
365
+ ```
366
+
367
+ ## Docker
368
+
369
+ ```bash
370
+ # Build the image
371
+ docker build -t termatplotlib .
372
+
373
+ # Run as CLI
374
+ docker run --rm termatplotlib -- --type bar --labels "A B C" --data "10 20 15"
375
+
376
+ # Run with pipe
377
+ echo "1,5,22,13,5" | docker run --rm -i termatplotlib --type sparkline --color green
378
+ ```
379
+
380
+ ## Scripts
381
+
382
+ | Script | Platform | Usage |
383
+ |--------|----------|-------|
384
+ | `run.sh` | Unix/macOS | `./run.sh bar --labels "A B" --data "10 20"` |
385
+ | `run.cmd` | Windows CMD | `run.cmd bar --labels "A B" --data "10 20"` |
386
+ | `run.ps1` | Windows PowerShell | `.\run.ps1 bar --labels "A B" --data "10 20"` |
387
+
388
+ ## Running Tests
389
+
390
+ ```bash
391
+ pytest
392
+ ```
393
+
394
+ ## Documentation
395
+
396
+ Full documentation is available in the `docs/` folder:
397
+
398
+ - [Overview](docs/index.md)
399
+ - [Installation](docs/installation.md)
400
+ - [Quick Start](docs/quickstart.md)
401
+ - [Chart Types](docs/chart-types.md)
402
+ - [API Reference](docs/api-reference.md)
403
+ - [Configuration](docs/configuration.md)
404
+ - [Advanced Features](docs/advanced.md)
405
+ - [Output & Formatting](docs/output.md)
406
+ - [Examples](docs/examples.md)
407
+ - [Contributing](docs/contributing.md)
408
+ - [Changelog](docs/changelog.md)
409
+
410
+ ## License
411
+
412
+ MIT