plotext-plus 1.0.9__py3-none-any.whl → 1.0.10__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.
- plotext_plus/__init__.py +20 -15
- plotext_plus/__main__.py +1 -0
- plotext_plus/_api.py +632 -371
- plotext_plus/_build.py +765 -149
- plotext_plus/_core.py +609 -164
- plotext_plus/_date.py +50 -32
- plotext_plus/_default.py +35 -28
- plotext_plus/_dict.py +807 -103
- plotext_plus/_doc.py +867 -296
- plotext_plus/_doc_utils.py +279 -245
- plotext_plus/_figure.py +1295 -303
- plotext_plus/_global.py +238 -140
- plotext_plus/_matrix.py +217 -63
- plotext_plus/_monitor.py +1036 -489
- plotext_plus/_output.py +29 -23
- plotext_plus/_shtab.py +2 -0
- plotext_plus/_themes.py +363 -247
- plotext_plus/_utility.py +581 -313
- plotext_plus/api.py +418 -332
- plotext_plus/charts.py +47 -24
- plotext_plus/core.py +570 -177
- plotext_plus/mcp_cli.py +15 -13
- plotext_plus/mcp_server.py +813 -332
- plotext_plus/plotext_cli.py +414 -275
- plotext_plus/plotting.py +86 -70
- plotext_plus/themes.py +10 -13
- plotext_plus/utilities.py +33 -33
- plotext_plus/utils.py +240 -140
- {plotext_plus-1.0.9.dist-info → plotext_plus-1.0.10.dist-info}/METADATA +7 -2
- plotext_plus-1.0.10.dist-info/RECORD +33 -0
- plotext_plus-1.0.9.dist-info/RECORD +0 -33
- {plotext_plus-1.0.9.dist-info → plotext_plus-1.0.10.dist-info}/WHEEL +0 -0
- {plotext_plus-1.0.9.dist-info → plotext_plus-1.0.10.dist-info}/entry_points.txt +0 -0
- {plotext_plus-1.0.9.dist-info → plotext_plus-1.0.10.dist-info}/licenses/LICENSE +0 -0
plotext_plus/_matrix.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import plotext_plus._utility as ut
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
|
|
4
|
+
class MatrixClass:
|
|
4
5
|
def __init__(self):
|
|
5
6
|
self.set_size(0, 0)
|
|
6
7
|
self.set_axes_color()
|
|
@@ -8,25 +9,28 @@ class matrix_class():
|
|
|
8
9
|
self.set_canvas_color()
|
|
9
10
|
self.set_matrices()
|
|
10
11
|
self.set_canvas()
|
|
11
|
-
|
|
12
|
+
|
|
12
13
|
def set_size(self, cols, rows):
|
|
13
|
-
self.rows = rows
|
|
14
|
-
self.
|
|
14
|
+
self.rows = rows
|
|
15
|
+
self.Rows = range(self.rows)
|
|
16
|
+
self.cols = cols
|
|
17
|
+
self.Cols = range(self.cols)
|
|
15
18
|
self.size = [self.rows, self.cols]
|
|
16
19
|
|
|
17
20
|
def update_size(self):
|
|
18
21
|
self.cols, self.rows = ut.matrix_size(self.marker)
|
|
19
|
-
self.Rows = range(self.rows)
|
|
22
|
+
self.Rows = range(self.rows)
|
|
23
|
+
self.Cols = range(self.cols)
|
|
20
24
|
self.size = [self.rows, self.cols]
|
|
21
25
|
|
|
22
|
-
def set_axes_color(self, color
|
|
26
|
+
def set_axes_color(self, color=ut.no_color):
|
|
23
27
|
self.axes_color = color
|
|
24
28
|
|
|
25
29
|
def set_canvas_area(self, col1, col2, row1, row2):
|
|
26
30
|
self.Cols_canvas = range(col1, col2)
|
|
27
31
|
self.Rows_canvas = range(row1, row2)
|
|
28
32
|
|
|
29
|
-
def set_canvas_color(self, color
|
|
33
|
+
def set_canvas_color(self, color=ut.no_color):
|
|
30
34
|
self.canvas_color = color
|
|
31
35
|
|
|
32
36
|
def in_canvas(self, col, row):
|
|
@@ -35,68 +39,207 @@ class matrix_class():
|
|
|
35
39
|
def set_matrices(self):
|
|
36
40
|
self.marker = [[ut.space] * self.cols for row in self.Rows]
|
|
37
41
|
self.fullground = [[ut.no_color] * self.cols for row in self.Rows]
|
|
38
|
-
get_background
|
|
39
|
-
|
|
42
|
+
def get_background(col, row):
|
|
43
|
+
return (
|
|
44
|
+
self.canvas_color if self.in_canvas(col, row) else self.axes_color
|
|
45
|
+
)
|
|
46
|
+
self.background = [
|
|
47
|
+
[get_background(col, row) for col in self.Cols] for row in self.Rows
|
|
48
|
+
]
|
|
40
49
|
self.style = [[ut.no_color] * self.cols for row in self.Rows]
|
|
41
50
|
|
|
42
51
|
def legal(self, col, row):
|
|
43
52
|
return col in self.Cols and row in self.Rows
|
|
44
53
|
|
|
45
54
|
def get_marker(self, col, row):
|
|
46
|
-
return self.marker[row][col]
|
|
55
|
+
return self.marker[row][col] # if self.legal(col, row) else "OUT"
|
|
47
56
|
|
|
48
57
|
def get_marker_row(self, row):
|
|
49
|
-
return self.marker[row]
|
|
58
|
+
return self.marker[row] # if self.legal(0, row) else "OUT"
|
|
50
59
|
|
|
51
60
|
def get_marker_col(self, col):
|
|
52
|
-
return [
|
|
61
|
+
return [
|
|
62
|
+
self.marker[r][col] for r in self.Rows
|
|
63
|
+
] # if self.legal(0, row) else "OUT"
|
|
53
64
|
|
|
54
65
|
def set_marker(self, col, row, marker):
|
|
55
66
|
self.marker[row][col] = marker
|
|
56
|
-
|
|
57
|
-
def set_fullground(self, col, row, fullground
|
|
67
|
+
|
|
68
|
+
def set_fullground(self, col, row, fullground=None):
|
|
58
69
|
self.fullground[row][col] = fullground
|
|
59
|
-
|
|
60
|
-
def set_background(self, col, row, background
|
|
70
|
+
|
|
71
|
+
def set_background(self, col, row, background=None):
|
|
61
72
|
self.background[row][col] = background
|
|
62
|
-
|
|
63
|
-
def set_style(self, col, row, style
|
|
73
|
+
|
|
74
|
+
def set_style(self, col, row, style=None):
|
|
64
75
|
self.style[row][col] = style
|
|
65
76
|
|
|
66
|
-
def insert_element(
|
|
67
|
-
|
|
77
|
+
def insert_element(
|
|
78
|
+
self,
|
|
79
|
+
col,
|
|
80
|
+
row,
|
|
81
|
+
marker,
|
|
82
|
+
fullground=None,
|
|
83
|
+
style=None,
|
|
84
|
+
background=None,
|
|
85
|
+
check_canvas=False,
|
|
86
|
+
):
|
|
87
|
+
test_canvas = (
|
|
88
|
+
True
|
|
89
|
+
if check_canvas is False
|
|
90
|
+
else col in self.Cols_canvas and row in self.Rows_canvas
|
|
91
|
+
)
|
|
68
92
|
if self.legal(col, row) and test_canvas:
|
|
69
93
|
self.set_marker(col, row, marker)
|
|
70
|
-
|
|
71
|
-
|
|
94
|
+
(
|
|
95
|
+
self.set_fullground(col, row, fullground)
|
|
96
|
+
if fullground is not None
|
|
97
|
+
else None
|
|
98
|
+
)
|
|
99
|
+
(
|
|
100
|
+
self.set_background(col, row, background)
|
|
101
|
+
if background is not None
|
|
102
|
+
else None
|
|
103
|
+
)
|
|
72
104
|
self.set_style(col, row, style) if style is not None else None
|
|
73
105
|
|
|
74
|
-
def add_horizontal_string(
|
|
75
|
-
|
|
76
|
-
col
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
106
|
+
def add_horizontal_string(
|
|
107
|
+
self,
|
|
108
|
+
col,
|
|
109
|
+
row,
|
|
110
|
+
string,
|
|
111
|
+
fullground=None,
|
|
112
|
+
style=None,
|
|
113
|
+
background=None,
|
|
114
|
+
alignment="left",
|
|
115
|
+
check_space=False,
|
|
116
|
+
check_canvas=False,
|
|
117
|
+
):
|
|
118
|
+
str_length = len(string)
|
|
119
|
+
char_indices = range(str_length)
|
|
120
|
+
col = (
|
|
121
|
+
col
|
|
122
|
+
if alignment == "left"
|
|
123
|
+
else (
|
|
124
|
+
col - str_length // 2
|
|
125
|
+
if alignment == "center"
|
|
126
|
+
else (
|
|
127
|
+
col - str_length + 1
|
|
128
|
+
if alignment == "right"
|
|
129
|
+
else ut.correct_coord(self.get_marker_row(row), string, col)
|
|
130
|
+
)
|
|
131
|
+
)
|
|
132
|
+
) # if dynamic
|
|
133
|
+
b, e = max(col - 1, 0), min(col + str_length + 1, self.cols)
|
|
134
|
+
test_space = (
|
|
135
|
+
all(self.get_marker(c, row) == ut.space for c in range(b, e))
|
|
136
|
+
and col >= 0
|
|
137
|
+
and col + str_length <= self.cols
|
|
138
|
+
if check_space
|
|
139
|
+
else True
|
|
140
|
+
)
|
|
141
|
+
(
|
|
142
|
+
[
|
|
143
|
+
self.insert_element(
|
|
144
|
+
col + i, row, string[i], fullground, style, background, check_canvas
|
|
145
|
+
)
|
|
146
|
+
for i in char_indices
|
|
147
|
+
]
|
|
148
|
+
if test_space
|
|
149
|
+
else None
|
|
150
|
+
)
|
|
80
151
|
return test_space
|
|
81
152
|
|
|
82
|
-
def add_vertical_string(
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
153
|
+
def add_vertical_string(
|
|
154
|
+
self,
|
|
155
|
+
col,
|
|
156
|
+
row,
|
|
157
|
+
string,
|
|
158
|
+
fullground=None,
|
|
159
|
+
style=None,
|
|
160
|
+
background=None,
|
|
161
|
+
alignment="bottom",
|
|
162
|
+
check_canvas=False,
|
|
163
|
+
):
|
|
164
|
+
str_length = len(string)
|
|
165
|
+
char_indices = range(str_length)
|
|
166
|
+
row = (
|
|
167
|
+
row
|
|
168
|
+
if alignment == "bottom"
|
|
169
|
+
else row - str_length // 2 if alignment == "center" else row - str_length + 1
|
|
170
|
+
) # if alignment == "top"
|
|
171
|
+
[
|
|
172
|
+
self.insert_element(
|
|
173
|
+
col, row + i, string[i], fullground, style, background, check_canvas
|
|
174
|
+
)
|
|
175
|
+
for i in char_indices
|
|
176
|
+
]
|
|
86
177
|
|
|
87
|
-
def add_multiple_horizontal_strings(
|
|
88
|
-
|
|
89
|
-
|
|
178
|
+
def add_multiple_horizontal_strings(
|
|
179
|
+
self,
|
|
180
|
+
col,
|
|
181
|
+
row,
|
|
182
|
+
string,
|
|
183
|
+
fullground=None,
|
|
184
|
+
style=None,
|
|
185
|
+
background=None,
|
|
186
|
+
alignment="left",
|
|
187
|
+
check_space=False,
|
|
188
|
+
check_canvas=False,
|
|
189
|
+
):
|
|
190
|
+
strings = "".join(string).split("\n")
|
|
191
|
+
string_count = len(strings)
|
|
192
|
+
[
|
|
193
|
+
self.add_horizontal_string(
|
|
194
|
+
col,
|
|
195
|
+
row - s,
|
|
196
|
+
strings[s],
|
|
197
|
+
fullground,
|
|
198
|
+
style,
|
|
199
|
+
background,
|
|
200
|
+
alignment,
|
|
201
|
+
check_space,
|
|
202
|
+
check_canvas,
|
|
203
|
+
)
|
|
204
|
+
for s in range(string_count)
|
|
205
|
+
]
|
|
90
206
|
|
|
91
|
-
def add_multiple_vertical_strings(
|
|
92
|
-
|
|
93
|
-
|
|
207
|
+
def add_multiple_vertical_strings(
|
|
208
|
+
self,
|
|
209
|
+
col,
|
|
210
|
+
row,
|
|
211
|
+
string,
|
|
212
|
+
fullground=None,
|
|
213
|
+
style=None,
|
|
214
|
+
background=None,
|
|
215
|
+
alignment="left",
|
|
216
|
+
check_canvas=False,
|
|
217
|
+
):
|
|
218
|
+
strings = "".join(string).split("\n")
|
|
219
|
+
string_count = len(strings)
|
|
220
|
+
[
|
|
221
|
+
self.add_vertical_string(
|
|
222
|
+
col + s,
|
|
223
|
+
row,
|
|
224
|
+
strings[s],
|
|
225
|
+
fullground,
|
|
226
|
+
style,
|
|
227
|
+
background,
|
|
228
|
+
alignment,
|
|
229
|
+
check_canvas,
|
|
230
|
+
)
|
|
231
|
+
for s in range(string_count)
|
|
232
|
+
]
|
|
94
233
|
|
|
95
234
|
def get_colors(self, col, row):
|
|
96
|
-
return [
|
|
235
|
+
return [
|
|
236
|
+
self.fullground[row][col],
|
|
237
|
+
self.style[row][col],
|
|
238
|
+
self.background[row][col],
|
|
239
|
+
] # if self.legal(col, row) else ["OUT"] * 3
|
|
97
240
|
|
|
98
241
|
def set_canvas(self):
|
|
99
|
-
canvas =
|
|
242
|
+
canvas = ""
|
|
100
243
|
for row in self.Rows[::-1]:
|
|
101
244
|
for col in self.Cols:
|
|
102
245
|
marker = self.marker[row][col]
|
|
@@ -106,13 +249,13 @@ class matrix_class():
|
|
|
106
249
|
canvas += ansi
|
|
107
250
|
canvas += marker
|
|
108
251
|
if col == self.cols - 1 or colors != self.get_colors(col + 1, row):
|
|
109
|
-
#ansi_next = colors_to_ansi(*colors_next)
|
|
110
|
-
canvas += ut.ansi_end
|
|
111
|
-
canvas +=
|
|
252
|
+
# ansi_next = colors_to_ansi(*colors_next)
|
|
253
|
+
canvas += ut.ansi_end # + ansi_next
|
|
254
|
+
canvas += "\n"
|
|
112
255
|
|
|
113
256
|
self.canvas = canvas
|
|
114
|
-
#print(repr(canvas))
|
|
115
|
-
#self.canvas = '\n'.join([''.join(self.marker[row]) for row in self.Rows])
|
|
257
|
+
# print(repr(canvas))
|
|
258
|
+
# self.canvas = '\n'.join([''.join(self.marker[row]) for row in self.Rows])
|
|
116
259
|
return self.canvas
|
|
117
260
|
|
|
118
261
|
def get_canvas(self):
|
|
@@ -124,48 +267,59 @@ class matrix_class():
|
|
|
124
267
|
self.background = ut.hstack(self.background, extra.background)
|
|
125
268
|
self.style = ut.hstack(self.style, extra.style)
|
|
126
269
|
self.update_size()
|
|
127
|
-
self.canvas =
|
|
128
|
-
|
|
270
|
+
self.canvas = ""
|
|
271
|
+
|
|
129
272
|
def vstack(self, extra):
|
|
130
273
|
self.marker = ut.vstack(self.marker, extra.marker)
|
|
131
274
|
self.fullground = ut.vstack(self.fullground, extra.fullground)
|
|
132
275
|
self.background = ut.vstack(self.background, extra.background)
|
|
133
276
|
self.style = ut.vstack(self.style, extra.style)
|
|
134
277
|
self.update_size()
|
|
135
|
-
self.canvas =
|
|
278
|
+
self.canvas = ""
|
|
136
279
|
|
|
137
|
-
def to_html(self):
|
|
138
|
-
code
|
|
139
|
-
|
|
140
|
-
html = "<body
|
|
280
|
+
def to_html(self): # turns a matrix of character in html form
|
|
281
|
+
def code(color):
|
|
282
|
+
return "rgb" + str(color).replace(" ", "")
|
|
283
|
+
# html = "<body>\n<p style=\"font-family:courier; font-size:11pt;\">\n\n"
|
|
284
|
+
html = '<body> \n <code style = style="font-family:courier; "font-size : 10pt;"> \n\n'
|
|
141
285
|
for r in range(self.rows - 1, -1, -1):
|
|
142
286
|
for c in range(self.cols):
|
|
143
287
|
marker = self.get_marker(c, r)
|
|
144
288
|
color, style, background = self.get_colors(c, r)
|
|
145
289
|
marker = " " if marker == ut.space else marker
|
|
146
|
-
marker =
|
|
147
|
-
marker =
|
|
148
|
-
color =
|
|
149
|
-
background =
|
|
290
|
+
marker = "<b>" + marker + "</b>" if style == "bold" else marker
|
|
291
|
+
marker = "<i>" + marker + "</i>" if style == "italic" else marker
|
|
292
|
+
color = "black" if color == ut.no_color else color
|
|
293
|
+
background = "white" if background == ut.no_color else background
|
|
150
294
|
color = ut.to_rgb(color)
|
|
151
295
|
background = ut.to_rgb(background)
|
|
152
296
|
color = code(color)
|
|
153
297
|
background = code(background)
|
|
154
|
-
html +=
|
|
298
|
+
html += (
|
|
299
|
+
'<span style = "color:'
|
|
300
|
+
+ color
|
|
301
|
+
+ "; background-color: "
|
|
302
|
+
+ background
|
|
303
|
+
+ '">'
|
|
304
|
+
+ marker
|
|
305
|
+
+ "</span>"
|
|
306
|
+
)
|
|
155
307
|
html += " <br>\n\n"
|
|
156
308
|
html += "<code> \n </body>"
|
|
157
309
|
return html
|
|
158
310
|
|
|
159
|
-
|
|
311
|
+
|
|
312
|
+
def join_matrices(
|
|
313
|
+
matrices,
|
|
314
|
+
): # from a matrix of MatrixClass() objects to a single matrix
|
|
160
315
|
cols, rows = ut.matrix_size(matrices)
|
|
161
|
-
|
|
316
|
+
main_matrix = MatrixClass()
|
|
162
317
|
for r in range(rows):
|
|
163
318
|
m_rows = matrices[r][0].rows
|
|
164
|
-
m =
|
|
319
|
+
m = MatrixClass()
|
|
165
320
|
m.set_size(0, m_rows)
|
|
166
321
|
m.set_matrices()
|
|
167
322
|
for c in range(cols):
|
|
168
323
|
m.hstack(matrices[r][c])
|
|
169
|
-
|
|
170
|
-
return
|
|
171
|
-
|
|
324
|
+
main_matrix.vstack(m)
|
|
325
|
+
return main_matrix
|