plotille 6.0.0__py3-none-any.whl

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.

Potentially problematic release.


This version of plotille might be problematic. Click here for more details.

@@ -0,0 +1,644 @@
1
+ Metadata-Version: 2.4
2
+ Name: plotille
3
+ Version: 6.0.0
4
+ Summary: Plot in the terminal using braille dots.
5
+ Keywords: plot,scatter,histogram,terminal,braille,unicode,timeseries
6
+ Author: Tammo Ippen
7
+ Author-email: Tammo Ippen <tammo.ippen@posteo.de>
8
+ License-Expression: MIT
9
+ Classifier: Environment :: Console
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Intended Audience :: Science/Research
12
+ Classifier: Programming Language :: Python
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Programming Language :: Python :: 3.14
19
+ Classifier: Programming Language :: Python :: Implementation :: CPython
20
+ Classifier: Programming Language :: Python :: Implementation :: PyPy
21
+ Classifier: Topic :: Scientific/Engineering :: Visualization
22
+ Classifier: Topic :: Terminals
23
+ Requires-Python: >=3.10, <4
24
+ Project-URL: Homepage, https://github.com/tammoippen/plotille
25
+ Project-URL: Repository, https://github.com/tammoippen/plotille
26
+ Description-Content-Type: text/markdown
27
+
28
+ ![Hero Plotille](https://github.com/tammoippen/plotille/raw/master/imgs/hero.png)
29
+
30
+ # Plotille
31
+
32
+ [![CI](https://github.com/tammoippen/plotille/actions/workflows/CI.yml/badge.svg)](https://github.com/tammoippen/plotille/actions/workflows/CI.yml)
33
+ [![codecov](https://codecov.io/gh/tammoippen/plotille/branch/master/graph/badge.svg?token=OGWI832JNM)](https://codecov.io/gh/tammoippen/plotille)
34
+ [![Tested CPython Versions](https://img.shields.io/badge/cpython-3.10%2C%203.11%2C%203.12%2C%203.13%2C%203.14-brightgreen.svg)](https://img.shields.io/badge/cpython-3.10%2C%203.11%2C%203.12%2C%203.13%203.14-brightgreen.svg)
35
+ [![Tested PyPy Versions](https://img.shields.io/badge/3.11-brightgreen.svg)](https://img.shields.io/badge/pypy-3.11-brightgreen.svg)
36
+ [![PyPi version](https://img.shields.io/pypi/v/plotille.svg)](https://pypi.python.org/pypi/plotille)
37
+ [![Downloads](https://pepy.tech/badge/plotille/month)](https://pepy.tech/project/plotille)
38
+ [![PyPi license](https://img.shields.io/pypi/l/plotille.svg)](https://pypi.python.org/pypi/plotille)
39
+ [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
40
+
41
+ Plots, scatter plots, histograms and heatmaps in the terminal using braille dots, and foreground and background colors - with no dependencies. Make complex figures using the Figure class or make fast and simple plots using graphing function - similar to a very small sibling to matplotlib. Or use the canvas to plot dots, lines and images yourself.
42
+
43
+ Install:
44
+
45
+ ```sh
46
+ pip install plotille
47
+ ```
48
+
49
+ Similar to other libraries:
50
+
51
+ - like [drawille](https://github.com/asciimoo/drawille), but focused on graphing – plus X/Y-axis.
52
+ - like [termplot](https://github.com/justnoise/termplot), but with braille (finer dots), left to right histogram and linear interpolation for plotting function.
53
+ - like [termgraph](https://github.com/sgeisler/termgraph) (not on pypi), but very different style.
54
+ - like [terminalplot](https://github.com/kressi/terminalplot), but with braille, X/Y-axis, histogram, linear interpolation.
55
+
56
+ Basic support for timeseries plotting is provided with release 3.2: for any `X` or `Y` values you can also add `datetime.datetime` or `numpy.datetime64` values. Labels are generated respecting the difference of `x_limits` and `y_limits`.
57
+
58
+ Support for heatmaps using background colors for figures and displaying images binary with braille, or in color with background colors using the canvas - provided with release 4.0
59
+
60
+ If you are still using python 2.7, please use plotille v4 or before. With v5 I am dropping support for python 2.7, as the effort to maintain the discontinued version is too much.
61
+
62
+ ## Documentation
63
+
64
+ ```python
65
+ In [1]: import plotille
66
+ In [2]: import numpy as np
67
+ In [3]: X = np.sort(np.random.normal(size=1000))
68
+ ```
69
+
70
+ ### Figure
71
+
72
+ To construct plots the recommended way is to use a `Figure`:
73
+
74
+ ```python
75
+ In [12]: plotille.Figure?
76
+ Init signature: plotille.Figure()
77
+ Docstring:
78
+ Figure class to compose multiple plots.
79
+
80
+ Within a Figure you can easily compose many plots, assign labels to plots
81
+ and define the properties of the underlying Canvas. Possible properties that
82
+ can be defined are:
83
+
84
+ width, height: int Define the number of characters in X / Y direction
85
+ which are used for plotting.
86
+ x_limits: float Define the X limits of the reference coordinate system,
87
+ that will be plottered.
88
+ y_limits: float Define the Y limits of the reference coordinate system,
89
+ that will be plottered.
90
+ color_mode: str Define the used color mode. See `plotille.color()`.
91
+ with_colors: bool Define, whether to use colors at all.
92
+ background: multiple Define the background color.
93
+ x_label, y_label: str Define the X / Y axis label.
94
+ ```
95
+
96
+ Basically, you create a `Figure`, define the properties and add your plots. Using the `show()` function, the `Figure` generates the plot using a new canvas:
97
+
98
+ ```python
99
+ In [13] fig = plotille.Figure()
100
+ In [14] fig.width = 60
101
+ In [15] fig.height = 30
102
+ In [16] fig.set_x_limits(min_=-3, max_=3)
103
+ In [17] fig.set_y_limits(min_=-1, max_=1)
104
+ In [18] fig.color_mode = 'byte'
105
+ In [19] fig.plot([-0.5, 1], [-1, 1], lc=25, label='First line')
106
+ In [20] fig.scatter(X, np.sin(X), lc=100, label='sin')
107
+ In [21] fig.plot(X, (X+2)**2 , lc=200, label='square')
108
+ In [22] print(fig.show(legend=True))
109
+ ```
110
+
111
+ ![Example figure](https://github.com/tammoippen/plotille/raw/master/imgs/figure.png)
112
+
113
+ The available plotting functions are:
114
+
115
+ ```python
116
+ # create a plot with linear interpolation between points
117
+ Figure.plot(self, X, Y, lc=None, interp='linear', label=None, marker=None)
118
+ # create a scatter plot with no interpolation between points
119
+ Figure.scatter(self, X, Y, lc=None, label=None, marker=None)
120
+ # create a histogram over X
121
+ Figure.histogram(self, X, bins=160, lc=None)
122
+ # print texts at coordinates X, Y
123
+ Figure.text(self, X, Y, texts, lc=None)
124
+
125
+ # The following functions use relative coordinates on the canvas
126
+ # i.e. all coordinates are \in [0, 1]
127
+ # plot a vertical line at x
128
+ Figure.axvline(self, x, ymin=0, ymax=1, lc=None)
129
+ # plot a vertical rectangle from (xmin,ymin) to (xmax, ymax).
130
+ Figure.axvspan(self, xmin, xmax, ymin=0, ymax=1, lc=None)
131
+ # plot a horizontal line at y
132
+ Figure.axhline(self, y, xmin=0, xmax=1, lc=None)
133
+ # plot a horizontal rectangle from (xmin,ymin) to (xmax, ymax).
134
+ Figure.axhspan(self, ymin, ymax, xmin=0, xmax=1, lc=None)
135
+
136
+ # Display data as an image, i.e. on a 2D regular raster.
137
+ Figure.imgshow(self, X, cmap=None)
138
+ ```
139
+
140
+ Other interesting functions are:
141
+
142
+ ```python
143
+ # remove all plots, texts, spans and images from the figure
144
+ Figure.clear(self)
145
+ # Create a canvas, plot the registered plots and return the string for displaying the plot
146
+ Figure.show(self, legend=False)
147
+ ```
148
+
149
+ Please have a look at the [`examples/`](./examples) folder.
150
+
151
+ ### Graphing
152
+
153
+ There are some utility functions for fast graphing of single plots.
154
+
155
+ #### Plot
156
+
157
+ ```python
158
+ In [4]: plotille.plot?
159
+ Signature:
160
+ plotille.plot(
161
+ X,
162
+ Y,
163
+ width=80,
164
+ height=40,
165
+ X_label='X',
166
+ Y_label='Y',
167
+ linesep=os.linesep,
168
+ interp='linear',
169
+ x_min=None,
170
+ x_max=None,
171
+ y_min=None,
172
+ y_max=None,
173
+ lc=None,
174
+ bg=None,
175
+ color_mode='names',
176
+ origin=True,
177
+ marker=None,
178
+ )
179
+ Docstring:
180
+ Create plot with X , Y values and linear interpolation between points
181
+
182
+ Parameters:
183
+ X: List[float] X values.
184
+ Y: List[float] Y values. X and Y must have the same number of entries.
185
+ width: int The number of characters for the width (columns) of the canvas.
186
+ height: int The number of characters for the height (rows) of the canvas.
187
+ X_label: str Label for X-axis.
188
+ Y_label: str Label for Y-axis. max 8 characters.
189
+ linesep: str The requested line separator. default: os.linesep
190
+ interp: Optional[str] Specify interpolation; values None, 'linear'
191
+ x_min, x_max: float Limits for the displayed X values.
192
+ y_min, y_max: float Limits for the displayed Y values.
193
+ lc: multiple Give the line color.
194
+ bg: multiple Give the background color.
195
+ color_mode: str Specify color input mode; 'names' (default), 'byte' or 'rgb'
196
+ see plotille.color.__docs__
197
+ origin: bool Whether to print the origin. default: True
198
+ marker: str Instead of braille dots set a marker char for actual values.
199
+
200
+ Returns:
201
+ str: plot over `X`, `Y`.
202
+
203
+ In [5]: print(plotille.plot(X, np.sin(X), height=30, width=60))
204
+ ```
205
+
206
+ ![Example plot](https://github.com/tammoippen/plotille/raw/master/imgs/plot.png)
207
+
208
+ #### Scatter
209
+
210
+ ```python
211
+ In [6]: plotille.scatter?
212
+ Signature:
213
+ plotille.scatter(
214
+ X,
215
+ Y,
216
+ width=80,
217
+ height=40,
218
+ X_label='X',
219
+ Y_label='Y',
220
+ linesep='\n',
221
+ x_min=None,
222
+ x_max=None,
223
+ y_min=None,
224
+ y_max=None,
225
+ lc=None,
226
+ bg=None,
227
+ color_mode='names',
228
+ origin=True,
229
+ marker=None,
230
+ )
231
+ Docstring:
232
+ Create scatter plot with X , Y values
233
+
234
+ Basically plotting without interpolation:
235
+ `plot(X, Y, ... , interp=None)`
236
+
237
+ Parameters:
238
+ X: List[float] X values.
239
+ Y: List[float] Y values. X and Y must have the same number of entries.
240
+ width: int The number of characters for the width (columns) of the canvas.
241
+ height: int The number of characters for the height (rows) of the canvas.
242
+ X_label: str Label for X-axis.
243
+ Y_label: str Label for Y-axis. max 8 characters.
244
+ linesep: str The requested line separator. default: os.linesep
245
+ x_min, x_max: float Limits for the displayed X values.
246
+ y_min, y_max: float Limits for the displayed Y values.
247
+ lc: multiple Give the line color.
248
+ bg: multiple Give the background color.
249
+ color_mode: str Specify color input mode; 'names' (default), 'byte' or 'rgb'
250
+ see plotille.color.__docs__
251
+ origin: bool Whether to print the origin. default: True
252
+ marker: str Instead of braille dots set a marker char.
253
+
254
+ Returns:
255
+ str: scatter plot over `X`, `Y`.
256
+
257
+ In [7]: print(plotille.scatter(X, np.sin(X), height=30, width=60))
258
+ ```
259
+
260
+ ![Example scatter](https://github.com/tammoippen/plotille/raw/master/imgs/scatter.png)
261
+
262
+ #### Hist
263
+
264
+ Inspired by [crappyhist](http://kevinastraight.x10host.com/2013/12/28/python-histograms-from-the-console/) (link is gone, but I made a [gist](https://gist.github.com/tammoippen/4474e838e969bf177155231ebba52386)).
265
+
266
+ ```python
267
+ In [8]: plotille.hist?
268
+ Signature:
269
+ plotille.hist(
270
+ X,
271
+ bins=40,
272
+ width=80,
273
+ log_scale=False,
274
+ linesep='\n',
275
+ lc=None,
276
+ bg=None,
277
+ color_mode='names',
278
+ )
279
+ Docstring:
280
+ Create histogram over `X` from left to right
281
+
282
+ The values on the left are the center of the bucket, i.e. `(bin[i] + bin[i+1]) / 2`.
283
+ The values on the right are the total counts of this bucket.
284
+
285
+ Parameters:
286
+ X: List[float] The items to count over.
287
+ bins: int The number of bins to put X entries in (rows).
288
+ width: int The number of characters for the width (columns).
289
+ log_scale: bool Scale the histogram with `log` function.
290
+ linesep: str The requested line separator. default: os.linesep
291
+ lc: multiple Give the line color.
292
+ bg: multiple Give the background color.
293
+ color_mode: str Specify color input mode; 'names' (default), 'byte' or 'rgb'
294
+ see plotille.color.__docs__
295
+
296
+ Returns:
297
+ str: histogram over `X` from left to right.
298
+
299
+ In [9]: print(plotille.hist(np.random.normal(size=10000)))
300
+ ```
301
+
302
+ ![Example hist](https://github.com/tammoippen/plotille/raw/master/imgs/hist.png)
303
+
304
+ #### Hist (aggregated)
305
+
306
+ This function allows you to create a histogram when your data is already aggregated (aka you don't have access to raw values, but you have access to bins and counts for each bin).
307
+
308
+ This comes handy when working with APIs such as [OpenTelemetry Metrics API](https://opentelemetry-python.readthedocs.io/en/latest/api/metrics.html)
309
+ where views such as [ExplicitBucketHistogramAggregation](https://opentelemetry-python.readthedocs.io/en/latest/sdk/metrics.view.html#opentelemetry.sdk.metrics.view.ExplicitBucketHistogramAggregation)
310
+ only expose access to aggregated values (counts for each bin / bucket).
311
+
312
+ ```python
313
+ In [8]: plotille.hist_aggregated?
314
+ Signature:
315
+ plotille.hist_aggregated(
316
+ counts,
317
+ bins,
318
+ width=80,
319
+ log_scale=False,
320
+ linesep='\n',
321
+ lc=None,
322
+ bg=None,
323
+ color_mode='names',
324
+ )
325
+ Docstring:
326
+ Create histogram for aggregated data.
327
+
328
+ Parameters:
329
+ counts: List[int] Counts for each bucket.
330
+ bins: List[float] Limits for the bins for the provided counts: limits for
331
+ bin `i` are `[bins[i], bins[i+1])`.
332
+ Hence, `len(bins) == len(counts) + 1`.
333
+ width: int The number of characters for the width (columns).
334
+ log_scale: bool Scale the histogram with `log` function.
335
+ linesep: str The requested line separator. default: os.linesep
336
+ lc: multiple Give the line color.
337
+ bg: multiple Give the background color.
338
+ color_mode: str Specify color input mode; 'names' (default), 'byte' or 'rgb'
339
+ see plotille.color.__docs__
340
+ Returns:
341
+ str: histogram over `X` from left to right.
342
+
343
+ In [9]: counts = [1945, 0, 0, 0, 0, 0, 10555, 798, 0, 28351, 0]
344
+ In [10]: bins = [float('-inf'), 10, 50, 100, 200, 300, 500, 800, 1000, 2000, 10000, float('+inf')]
345
+ In [11]: print(plotille.hist_aggregated(counts, bins))
346
+ ```
347
+
348
+ Keep in mind that there must always be n+1 bins (n is a total number of count values, 11 in the example above).
349
+
350
+ In this example the first bin is from [-inf, 10) with a count of 1945 and the last bin is from [10000, +inf] with a count of 0.
351
+
352
+ ![Example hist](https://github.com/tammoippen/plotille/raw/master/imgs/hist_aggregated.png)
353
+
354
+ #### Histogram
355
+
356
+ There is also another more 'usual' histogram function available:
357
+
358
+ ```python
359
+ In [10]: plotille.histogram?
360
+ Signature:
361
+ plotille.histogram(
362
+ X,
363
+ bins=160,
364
+ width=80,
365
+ height=40,
366
+ X_label='X',
367
+ Y_label='Counts',
368
+ linesep='\n',
369
+ x_min=None,
370
+ x_max=None,
371
+ y_min=None,
372
+ y_max=None,
373
+ lc=None,
374
+ bg=None,
375
+ color_mode='names',
376
+ )
377
+ Docstring:
378
+ Create histogram over `X`
379
+
380
+ In contrast to `hist`, this is the more `usual` histogram from bottom
381
+ to up. The X-axis represents the values in `X` and the Y-axis is the
382
+ corresponding frequency.
383
+
384
+ Parameters:
385
+ X: List[float] The items to count over.
386
+ bins: int The number of bins to put X entries in (columns).
387
+ height: int The number of characters for the height (rows).
388
+ X_label: str Label for X-axis.
389
+ Y_label: str Label for Y-axis. max 8 characters.
390
+ linesep: str The requested line separator. default: os.linesep
391
+ x_min, x_max: float Limits for the displayed X values.
392
+ y_min, y_max: float Limits for the displayed Y values.
393
+ lc: multiple Give the line color.
394
+ bg: multiple Give the background color.
395
+ color_mode: str Specify color input mode; 'names' (default), 'byte' or 'rgb'
396
+ see plotille.color.__docs__
397
+
398
+ Returns:
399
+ str: histogram over `X`.
400
+
401
+ In [11]: print(plotille.histogram(np.random.normal(size=10000)))
402
+ ```
403
+
404
+ ![Example histogram](https://github.com/tammoippen/plotille/raw/master/imgs/histogram.png)
405
+
406
+ ### Canvas
407
+
408
+ The underlying plotting area is modeled as the `Canvas` class:
409
+
410
+ ```python
411
+ In [12]: plotille.Canvas?
412
+ Init signature:
413
+ plotille.Canvas(
414
+ width,
415
+ height,
416
+ xmin=0,
417
+ ymin=0,
418
+ xmax=1,
419
+ ymax=1,
420
+ background=None,
421
+ **color_kwargs,
422
+ )
423
+ Docstring:
424
+ A canvas object for plotting braille dots
425
+
426
+ A Canvas object has a `width` x `height` characters large canvas, in which it
427
+ can plot indivitual braille point, lines out of braille points, rectangles,...
428
+ Since a full braille character has 2 x 4 dots (⣿), the canvas has `width` * 2, `height` * 4
429
+ dots to plot into in total.
430
+
431
+ It maintains two coordinate systems: a reference system with the limits (xmin, ymin)
432
+ in the lower left corner to (xmax, ymax) in the upper right corner is transformed
433
+ into the canvas discrete, i.e. dots, coordinate system (0, 0) to (`width` * 2, `height` * 4).
434
+ It does so transparently to clients of the Canvas, i.e. all plotting functions
435
+ only accept coordinates in the reference system. If the coordinates are outside
436
+ the reference system, they are not plotted.
437
+ Init docstring:
438
+ Initiate a Canvas object
439
+
440
+ Parameters:
441
+ width: int The number of characters for the width (columns) of the canvas.
442
+ height: int The number of characters for the height (rows) of the canvas.
443
+ xmin, ymin: float Lower left corner of reference system.
444
+ xmax, ymax: float Upper right corner of reference system.
445
+ background: multiple Background color of the canvas.
446
+ **color_kwargs: More arguments to the color-function. See `plotille.color()`.
447
+
448
+ Returns:
449
+ Canvas object
450
+ ```
451
+
452
+ The most interesting functions are:
453
+
454
+ _point:_
455
+
456
+ ```python
457
+ In [11]: plotille.Canvas.point?
458
+ Signature: plotille.Canvas.point(self, x, y, set_=True, color=None, marker=None)
459
+ Docstring:
460
+ Put a point into the canvas at (x, y) [reference coordinate system]
461
+
462
+ Parameters:
463
+ x: float x-coordinate on reference system.
464
+ y: float y-coordinate on reference system.
465
+ set_: bool Whether to plot or remove the point.
466
+ color: multiple Color of the point.
467
+ marker: str Instead of braille dots set a marker char.
468
+ ```
469
+
470
+ _line:_
471
+
472
+ ```python
473
+ In [14]: plotille.Canvas.line?
474
+ Signature: plotille.Canvas.line(self, x0, y0, x1, y1, set_=True, color=None)
475
+ Docstring:
476
+ Plot line between point (x0, y0) and (x1, y1) [reference coordinate system].
477
+
478
+ Parameters:
479
+ x0, y0: float Point 0
480
+ x1, y1: float Point 1
481
+ set_: bool Whether to plot or remove the line.
482
+ color: multiple Color of the line.
483
+ ```
484
+
485
+ _rect:_
486
+
487
+ ```python
488
+ In [15]: plotille.Canvas.rect?
489
+ Signature: plotille.Canvas.rect(self, xmin, ymin, xmax, ymax, set_=True, color=None)
490
+ Docstring:
491
+ Plot rectangle with bbox (xmin, ymin) and (xmax, ymax) [reference coordinate system].
492
+
493
+ Parameters:
494
+ xmin, ymin: float Lower left corner of rectangle.
495
+ xmax, ymax: float Upper right corner of rectangle.
496
+ set_: bool Whether to plot or remove the rect.
497
+ color: multiple Color of the rect.
498
+ ```
499
+
500
+ _text:_
501
+
502
+ ```python
503
+ In [16]: plotille.Canvas.text?
504
+ Signature: plotille.Canvas.text(self, x, y, text, set_=True, color=None)
505
+ Docstring:
506
+ Put some text into the canvas at (x, y) [reference coordinate system]
507
+
508
+ Parameters:
509
+ x: float x-coordinate on reference system.
510
+ y: float y-coordinate on reference system.
511
+ set_: bool Whether to set the text or clear the characters.
512
+ text: str The text to add.
513
+ color: multiple Color of the point.
514
+ ```
515
+
516
+ _braille_image:_
517
+
518
+ ```python
519
+ In [17]: plotille.Canvas.braille_image?
520
+ Signature:
521
+ plotille.Canvas.braille_image(
522
+ self,
523
+ pixels,
524
+ threshold=127,
525
+ inverse=False,
526
+ set_=True,
527
+ )
528
+ Docstring:
529
+ Print an image using braille dots into the canvas.
530
+
531
+ The pixels and braille dots in the canvas are a 1-to-1 mapping, hence
532
+ a 80 x 80 pixel image will need a 40 x 20 canvas.
533
+
534
+ Example:
535
+ from PIL import Image
536
+ import plotille as plt
537
+
538
+ img = Image.open("/path/to/image")
539
+ img = img.convert('L')
540
+ img = img.resize((80, 80))
541
+ cvs = plt.Canvas(40, 20)
542
+ cvs.braille_image(img.getdata(), 125)
543
+ print(cvs.plot())
544
+
545
+ Parameters:
546
+ pixels: list[number] All pixels of the image in one list.
547
+ threshold: float All pixels above this threshold will be
548
+ drawn.
549
+ inverse: bool Whether to invert the image.
550
+ set_: bool Whether to plot or remove the dots.
551
+ ```
552
+
553
+ _image:_
554
+
555
+ ```python
556
+ In [18]: plotille.Canvas.image?
557
+ Signature: plotille.Canvas.image(self, pixels, set_=True)
558
+ Docstring:
559
+ Print an image using background colors into the canvas.
560
+
561
+ The pixels of the image and the characters in the canvas are a
562
+ 1-to-1 mapping, hence a 80 x 80 image will need a 80 x 80 canvas.
563
+
564
+ Example:
565
+ from PIL import Image
566
+ import plotille as plt
567
+
568
+ img = Image.open("/path/to/image")
569
+ img = img.convert('RGB')
570
+ img = img.resize((40, 40))
571
+ cvs = plt.Canvas(40, 40, mode='rgb')
572
+ cvs.image(img.getdata())
573
+ print(cvs.plot())
574
+
575
+ Parameters:
576
+ pixels: list[(R,G,B)] All pixels of the image in one list.
577
+ set_: bool Whether to plot or remove the background
578
+ colors.
579
+ ```
580
+
581
+ _plot:_
582
+
583
+ ```python
584
+ In [16]: plotille.Canvas.plot?
585
+ Signature: plotille.Canvas.plot(self, linesep='\n')
586
+ Docstring:
587
+ Transform canvas into `print`-able string
588
+
589
+ Parameters:
590
+ linesep: str The requested line separator. default: os.linesep
591
+
592
+ Returns:
593
+ unicode: The canvas as a string.
594
+ ```
595
+
596
+ You can use it for example to plot a house in the terminal:
597
+
598
+ ```python
599
+ In [17]: c = Canvas(width=40, height=20)
600
+ In [18]: c.rect(0.1, 0.1, 0.6, 0.6)
601
+ In [19]: c.line(0.1, 0.1, 0.6, 0.6)
602
+ In [20]: c.line(0.1, 0.6, 0.6, 0.1)
603
+ In [21]: c.line(0.1, 0.6, 0.35, 0.8)
604
+ In [22]: c.line(0.35, 0.8, 0.6, 0.6)
605
+ In [23]: print(c.plot())
606
+ ```
607
+
608
+ ![House](https://github.com/tammoippen/plotille/raw/master/imgs/house.png)
609
+
610
+ Or you could render images with braille dots:
611
+
612
+ ```python
613
+ In [24]: img = Image.open('https://github.com/tammoippen/plotille/raw/master/imgs/ich.jpg')
614
+ In [25]: img = img.convert('L')
615
+ In [26]: img = img.resize((80, 80))
616
+ In [27]: cvs = Canvas(40, 20)
617
+ In [28]: cvs.braille_image(img.getdata())
618
+ In [29]: print(cvs.plot())
619
+ ```
620
+
621
+ ![Me with dots](https://github.com/tammoippen/plotille/raw/master/imgs/ich-dots.png)
622
+
623
+ Or you could render images with the background color of characters:
624
+
625
+ ```python
626
+ In [24]: img = Image.open('https://github.com/tammoippen/plotille/raw/master/imgs/ich.jpg')
627
+ In [25]: img = img.convert('RGB')
628
+ In [25]: img = img.resize((80, 40))
629
+ In [27]: cvs = Canvas(80, 40, mode="rgb")
630
+ In [28]: cvs.image(img.getdata())
631
+ In [29]: print(cvs.plot())
632
+ ```
633
+
634
+ ![Me with chars](https://github.com/tammoippen/plotille/raw/master/imgs/ich-chars.png)
635
+
636
+ ## Stargazers over time
637
+
638
+ [![Stargazers over time](https://starchart.cc/tammoippen/plotille.svg)](https://starchart.cc/tammoippen/plotille)
639
+
640
+ ## Sponsoring the project
641
+
642
+ If you like the project and want to buy me a coffee, feel free to send some coins ;)
643
+
644
+ [<img src="https://api.gitsponsors.com/api/badge/img?id=105019800" height="20">](https://api.gitsponsors.com/api/badge/link?p=gkBol1u2+g2pjgZGRaDLy4k0XbPDRXdPWJWnueCUGo/wcSsqyE8nr+n9nvqfeuqXee6JhLARGZS5bP0ZvorS7y6t4INyHLtTrprYh9c+MYkqAZeSqNIf7WL0ZRTI070RVQA3L9QW9IZNFlMbulW+BQ==)
@@ -0,0 +1,16 @@
1
+ plotille/__init__.py,sha256=928262be004083f050e7cd5f028a24c1bb92f9cb5d590df365afbe74d0213569,1523
2
+ plotille/_canvas.py,sha256=195941c825c76695ba89054b8f4c9232d5643498c9fba70c0d8f15238a98667d,16017
3
+ plotille/_cmaps.py,sha256=ab994f837caf1d6fbf43bec96797d4fe07c549d043dee34774dd882a9d47db6f,4541
4
+ plotille/_cmaps_data.py,sha256=723bdaa68ff2f6d581723e6d12e86c47c2373300daa7cdfc7e70ab118e0dfcf0,55027
5
+ plotille/_colors.py,sha256=eaa3e0cdc627a21f02a50979abe2ddd186815481c3ab29a07d8c26e3c4e453af,11859
6
+ plotille/_data_metadata.py,sha256=43a370d19c37288037b809070250ef3adae6fd50148e9add027b59c28eec79c8,3437
7
+ plotille/_dots.py,sha256=6a7dd240595e7c00454f7b9e0866112f8875bbab84fe717a34177ba706837f88,5912
8
+ plotille/_figure.py,sha256=df696e1965be52a7189728aac255225022cef87cf48c94be413b9da539342163,34645
9
+ plotille/_figure_data.py,sha256=df9cb3f026cc031928d7257e75028b32992caa9e87adec12703b5623de883c3c,10439
10
+ plotille/_graphs.py,sha256=dd5d6c3523390b2b7f7187ef0372fb2391656930c04b52a06b38e5f30a2046d7,12942
11
+ plotille/_input_formatter.py,sha256=e68ec1f225f5c79259cb873b60336b06e5c28f6201b11bd930bf32681c97b632,8326
12
+ plotille/_util.py,sha256=35ce5a38f9b9b2f52e14d5bdaf35f2f1afa8d0c5106a393c9f55a146ca4eab1b,3101
13
+ plotille/data.py,sha256=7d8050585a5fdfffc0ee985edcdf136f932cd8df228a3175e71d5f435e4bea13,3734
14
+ plotille-6.0.0.dist-info/WHEEL,sha256=ab6157bc637547491fb4567cd7ddf26b04d63382916ca16c29a5c8e94c9c9ef7,79
15
+ plotille-6.0.0.dist-info/METADATA,sha256=13e94ac2232466e060738de52f253b731f74aaa76e8844229c998d8b930f9393,22849
16
+ plotille-6.0.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: uv 0.7.22
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any