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/plotext_cli.py
CHANGED
|
@@ -1,244 +1,340 @@
|
|
|
1
1
|
#!/usr/bin/env python
|
|
2
|
-
|
|
3
|
-
import
|
|
2
|
+
import argparse
|
|
3
|
+
import os
|
|
4
|
+
import sys
|
|
5
|
+
|
|
4
6
|
import plotext_plus as plt
|
|
7
|
+
from plotext_plus._utility import all_markers
|
|
8
|
+
from plotext_plus._utility import colors
|
|
9
|
+
|
|
5
10
|
try:
|
|
6
11
|
import shtab
|
|
7
12
|
except ImportError:
|
|
8
13
|
from . import _shtab as shtab
|
|
9
14
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
15
|
+
|
|
16
|
+
# For Possible Colors and Markers Completion
|
|
17
|
+
def dict_to_complete(d=None):
|
|
18
|
+
if d is None:
|
|
19
|
+
d = {}
|
|
20
|
+
return {
|
|
21
|
+
"zsh": "(("
|
|
22
|
+
+ " ".join(str(x[0]) + "\\:" + x[1] for x in d.items())
|
|
23
|
+
+ "))"
|
|
24
|
+
}
|
|
25
|
+
|
|
13
26
|
|
|
14
27
|
def list_to_complete(data):
|
|
15
|
-
return {
|
|
28
|
+
return {"zsh": "((" + " ".join([el + "\\:" for el in data]) + "))"}
|
|
16
29
|
|
|
17
30
|
|
|
18
31
|
def build_parser():
|
|
19
|
-
|
|
32
|
+
|
|
20
33
|
examples = """Access each function documentation for further guidance, eg: plotext scatter -h"""
|
|
21
34
|
|
|
22
35
|
parser = argparse.ArgumentParser(
|
|
23
|
-
prog
|
|
24
|
-
description
|
|
25
|
-
epilog
|
|
26
|
-
formatter_class
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
data_parser.add_argument(
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
options_parser.add_argument(
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
36
|
+
prog="plotext",
|
|
37
|
+
description="plotting directly on terminal",
|
|
38
|
+
epilog=examples,
|
|
39
|
+
formatter_class=argparse.RawDescriptionHelpFormatter,
|
|
40
|
+
)
|
|
41
|
+
shtab.add_argument_to(parser, ["-s", "--print-completion"])
|
|
42
|
+
|
|
43
|
+
parser.set_defaults(type="scatter")
|
|
44
|
+
|
|
45
|
+
path_parser = argparse.ArgumentParser(add_help=False)
|
|
46
|
+
|
|
47
|
+
path_parser.add_argument(
|
|
48
|
+
"-p",
|
|
49
|
+
"--path",
|
|
50
|
+
action="store",
|
|
51
|
+
# dest = 'path',
|
|
52
|
+
type=str,
|
|
53
|
+
metavar="FILE",
|
|
54
|
+
help="file path of the data table; if not used it will read from stdin. Use 'test' to automatically download, in your user folder, some test data/image/gif or video, depending on the function used; the file will be removed after the plot",
|
|
55
|
+
).complete = shtab.FILE
|
|
56
|
+
path_parser.add_argument(
|
|
57
|
+
"-r",
|
|
58
|
+
"--first-row",
|
|
59
|
+
action="store",
|
|
60
|
+
type=int,
|
|
61
|
+
default=0,
|
|
62
|
+
metavar="FIRST-ROW",
|
|
63
|
+
help="The first line to consider in the data file (counting from 0).",
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
common_parser = argparse.ArgumentParser(add_help=False)
|
|
67
|
+
|
|
68
|
+
common_parser.add_argument(
|
|
69
|
+
"-clt",
|
|
70
|
+
"--clear_terminal",
|
|
71
|
+
nargs=1,
|
|
72
|
+
type=str,
|
|
73
|
+
default=["False"],
|
|
74
|
+
choices=["True", "False"],
|
|
75
|
+
metavar="BOOL",
|
|
76
|
+
help="it clears the terminal before plotting, if True (as by default)",
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
common_parser.add_argument(
|
|
80
|
+
"-s",
|
|
81
|
+
"--sleep",
|
|
82
|
+
nargs=1,
|
|
83
|
+
type=float,
|
|
84
|
+
default=[0],
|
|
85
|
+
help="it adds a sleeping time after plotting, to reduce flickering when multiple plots are required; 0 by default",
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
data_parser = argparse.ArgumentParser(add_help=False)
|
|
89
|
+
|
|
90
|
+
data_parser.add_argument(
|
|
91
|
+
"-xcol",
|
|
92
|
+
"--xcolumn",
|
|
93
|
+
nargs="+", # 1 or more
|
|
94
|
+
type=str,
|
|
95
|
+
default=["none"],
|
|
96
|
+
help="the column number (starting from 1), in the data table, that will be used as x data; by default 'none'",
|
|
97
|
+
)
|
|
98
|
+
|
|
99
|
+
data_parser.add_argument(
|
|
100
|
+
"-ycols",
|
|
101
|
+
"--ycolumns",
|
|
102
|
+
nargs="+", # 1 or more
|
|
103
|
+
type=str,
|
|
104
|
+
default=["all"],
|
|
105
|
+
help="the column numbers (starting from 1), in the data table, that will be used as y data; by default 'all'",
|
|
106
|
+
)
|
|
107
|
+
|
|
108
|
+
data_parser.add_argument(
|
|
109
|
+
"-d",
|
|
110
|
+
"--delimiter",
|
|
111
|
+
type=str,
|
|
112
|
+
default=[" "],
|
|
113
|
+
nargs=1,
|
|
114
|
+
help="character to be used to separate columns in the data table (eg: ;); by default the white space ' '",
|
|
115
|
+
)
|
|
116
|
+
|
|
117
|
+
data_parser.add_argument(
|
|
118
|
+
"-l",
|
|
119
|
+
"--lines",
|
|
120
|
+
nargs="+", # 1 or more
|
|
121
|
+
type=int,
|
|
122
|
+
default=[1000],
|
|
123
|
+
help="number of lines, from data table, to be plotted at each iteration; 1000 by default; data shorter then this will be plotted in a single iteration",
|
|
124
|
+
)
|
|
125
|
+
|
|
126
|
+
options_parser = argparse.ArgumentParser(add_help=False)
|
|
127
|
+
|
|
128
|
+
options_parser.add_argument(
|
|
129
|
+
"-m",
|
|
130
|
+
"--marker",
|
|
131
|
+
type=str,
|
|
132
|
+
default=["hd"],
|
|
133
|
+
nargs=1,
|
|
134
|
+
choices=all_markers.keys(),
|
|
135
|
+
metavar="marker",
|
|
136
|
+
help="character or marker code identifying the data points in the plot, eg: x, braille, sd, heart, fhd; by default hd",
|
|
137
|
+
).complete = dict_to_complete(all_markers)
|
|
138
|
+
|
|
139
|
+
options_parser.add_argument(
|
|
140
|
+
"-c",
|
|
141
|
+
"--color",
|
|
142
|
+
type=str,
|
|
143
|
+
default=[None],
|
|
144
|
+
nargs=1,
|
|
145
|
+
choices=colors,
|
|
146
|
+
metavar="COLOR",
|
|
147
|
+
help="color of the data points in the plot, between: "
|
|
148
|
+
+ ",".join(colors)
|
|
149
|
+
+ "; add + at the end of the color (except black and white) for clearer colors, eg: red+",
|
|
150
|
+
).complete = list_to_complete(colors)
|
|
151
|
+
|
|
152
|
+
options_parser.add_argument(
|
|
153
|
+
"-t", "--title", nargs=1, type=str, default=[None], help="the plot title"
|
|
154
|
+
)
|
|
155
|
+
|
|
156
|
+
options_parser.add_argument(
|
|
157
|
+
"-xl",
|
|
158
|
+
"--xlabel",
|
|
159
|
+
nargs=1,
|
|
160
|
+
type=str,
|
|
161
|
+
default=[None],
|
|
162
|
+
help="the label of the x axis",
|
|
163
|
+
)
|
|
164
|
+
|
|
165
|
+
options_parser.add_argument(
|
|
166
|
+
"-yl",
|
|
167
|
+
"--ylabel",
|
|
168
|
+
nargs=1,
|
|
169
|
+
type=str,
|
|
170
|
+
default=[None],
|
|
171
|
+
help="the label of the y axis",
|
|
172
|
+
)
|
|
173
|
+
|
|
174
|
+
options_parser.add_argument(
|
|
175
|
+
"-g",
|
|
176
|
+
"--grid",
|
|
177
|
+
nargs=1,
|
|
178
|
+
type=str,
|
|
179
|
+
default=["False"],
|
|
180
|
+
choices=["True", "False"],
|
|
181
|
+
metavar="BOOL",
|
|
182
|
+
help="it add grid lines if True, or removed them if False (as by default)",
|
|
183
|
+
)
|
|
184
|
+
|
|
185
|
+
barhist_parser = argparse.ArgumentParser(add_help=False)
|
|
186
|
+
|
|
187
|
+
barhist_parser.add_argument(
|
|
188
|
+
"-o",
|
|
189
|
+
"--orientation",
|
|
190
|
+
nargs=1,
|
|
191
|
+
type=str,
|
|
192
|
+
default=["v"],
|
|
193
|
+
choices=["v", "h"],
|
|
194
|
+
metavar="ORIENTATION",
|
|
195
|
+
help="bar orientation, v for vertical (as by default), h for horizontal",
|
|
196
|
+
)
|
|
197
|
+
|
|
198
|
+
barhist_parser.add_argument(
|
|
199
|
+
"-f",
|
|
200
|
+
"--fill",
|
|
201
|
+
nargs=1,
|
|
202
|
+
type=str,
|
|
203
|
+
default=["True"],
|
|
204
|
+
choices=["True", "False"],
|
|
205
|
+
metavar="BOOL",
|
|
206
|
+
help="it fills the bars with colored markers if True (as by default), otherwise only the bars skeleton is shown",
|
|
207
|
+
)
|
|
208
|
+
|
|
209
|
+
subparser = parser.add_subparsers(dest="type", help="the user defined plot type")
|
|
210
|
+
|
|
211
|
+
subparser.add_parser(
|
|
212
|
+
"scatter",
|
|
213
|
+
description="plots a series of data points",
|
|
214
|
+
parents=[path_parser, data_parser, common_parser, options_parser],
|
|
215
|
+
help="plots a series of data points",
|
|
216
|
+
epilog="eg: plotext scatter --path test --xcolumn 1 --ycolumns 2 --lines 5000 --title 'Scatter Plot Test' --marker braille",
|
|
217
|
+
)
|
|
218
|
+
|
|
219
|
+
subparser.add_parser(
|
|
220
|
+
"plot",
|
|
221
|
+
parents=[path_parser, data_parser, common_parser, options_parser],
|
|
222
|
+
description="plots lines between consecutive data points",
|
|
223
|
+
help="plots lines between consecutive data points",
|
|
224
|
+
epilog="eg: plotext plot --path test --xcolumn 1 --ycolumns 2 --sleep 0.1 --lines 2500 --clear_terminal True --color magenta+ --title 'Plot Test'",
|
|
225
|
+
)
|
|
226
|
+
|
|
227
|
+
subparser.add_parser(
|
|
228
|
+
"plotter",
|
|
229
|
+
parents=[path_parser, data_parser, common_parser, options_parser],
|
|
230
|
+
description="plots a series of data points and the lines between consecutive ones",
|
|
231
|
+
help="scatter + plot",
|
|
232
|
+
epilog="eg:plotext plotter --path test --xcolumn 1 --ycolumns 2 --sleep 0.1 --lines 120 --clear_terminal True --marker hd --title 'Plotter Test'",
|
|
233
|
+
)
|
|
234
|
+
|
|
235
|
+
bar = subparser.add_parser(
|
|
236
|
+
"bar",
|
|
237
|
+
parents=[
|
|
238
|
+
path_parser,
|
|
239
|
+
data_parser,
|
|
240
|
+
common_parser,
|
|
241
|
+
options_parser,
|
|
242
|
+
barhist_parser,
|
|
243
|
+
],
|
|
244
|
+
description="builds a bar plot",
|
|
245
|
+
help="bar plot",
|
|
246
|
+
epilog="eg: plotext bar --path test --xcolumn 1 --title 'Bar Plot Test' --xlabel Animals --ylabel Count",
|
|
247
|
+
)
|
|
248
|
+
|
|
249
|
+
bar.add_argument(
|
|
250
|
+
"-w",
|
|
251
|
+
"--width",
|
|
252
|
+
nargs=1,
|
|
253
|
+
type=float,
|
|
254
|
+
default=[None],
|
|
255
|
+
help="bars width as a float between 0 and 1",
|
|
256
|
+
)
|
|
257
|
+
|
|
258
|
+
hist = subparser.add_parser(
|
|
259
|
+
"hist",
|
|
260
|
+
parents=[
|
|
261
|
+
path_parser,
|
|
262
|
+
data_parser,
|
|
263
|
+
common_parser,
|
|
264
|
+
options_parser,
|
|
265
|
+
barhist_parser,
|
|
266
|
+
],
|
|
267
|
+
description="builds a histogram plot",
|
|
268
|
+
help="histogram plot",
|
|
269
|
+
epilog="eg: plotext hist --path test --xcolumn 1 --ycolumns 2 --lines 5000 --title 'Histogram Test'",
|
|
270
|
+
)
|
|
271
|
+
|
|
272
|
+
hist.add_argument(
|
|
273
|
+
"-b",
|
|
274
|
+
"--bins",
|
|
275
|
+
nargs=1,
|
|
276
|
+
type=int,
|
|
277
|
+
default=[10],
|
|
278
|
+
help="histogram bins (10 by default)",
|
|
279
|
+
)
|
|
280
|
+
|
|
281
|
+
subparser.add_parser(
|
|
282
|
+
"image",
|
|
283
|
+
parents=[path_parser, common_parser],
|
|
284
|
+
description="plots an image from path",
|
|
285
|
+
help="plots an image from file path",
|
|
286
|
+
epilog="eg: plotext image --path test",
|
|
287
|
+
)
|
|
288
|
+
|
|
289
|
+
subparser.add_parser(
|
|
290
|
+
"gif",
|
|
291
|
+
parents=[path_parser, common_parser],
|
|
292
|
+
description="plays a gif image from path",
|
|
293
|
+
help="plays a gif image from path",
|
|
294
|
+
epilog="eg: plotext gif --path test",
|
|
295
|
+
)
|
|
296
|
+
|
|
297
|
+
video = subparser.add_parser(
|
|
298
|
+
"video",
|
|
299
|
+
parents=[path_parser, common_parser],
|
|
300
|
+
description="plays a video from path",
|
|
301
|
+
help="plays a video from path",
|
|
302
|
+
epilog="eg: plotext video --path test --from_youtube True",
|
|
303
|
+
)
|
|
304
|
+
|
|
305
|
+
video.add_argument(
|
|
306
|
+
"-fy",
|
|
307
|
+
"--from_youtube",
|
|
308
|
+
nargs=1,
|
|
309
|
+
type=str,
|
|
310
|
+
default=["False"],
|
|
311
|
+
choices=["True", "False"],
|
|
312
|
+
metavar="BOOL",
|
|
313
|
+
help="set it to True to render the colors correctly for videos downloaded from youtube; default is False",
|
|
314
|
+
)
|
|
315
|
+
|
|
316
|
+
youtube = subparser.add_parser(
|
|
317
|
+
"youtube",
|
|
318
|
+
description="plays a youtube video from url",
|
|
319
|
+
help="plays a youtube video from url",
|
|
320
|
+
epilog="eg: plotext youtube --url test",
|
|
321
|
+
)
|
|
322
|
+
|
|
323
|
+
youtube.add_argument(
|
|
324
|
+
"-u",
|
|
325
|
+
"--url",
|
|
326
|
+
action="store",
|
|
327
|
+
dest="url",
|
|
328
|
+
nargs=1,
|
|
329
|
+
type=str,
|
|
330
|
+
metavar="URL",
|
|
331
|
+
help="the url of a youtube video; use 'test' for a test video",
|
|
332
|
+
)
|
|
237
333
|
|
|
238
334
|
return parser
|
|
239
335
|
|
|
240
336
|
|
|
241
|
-
def main(argv
|
|
337
|
+
def main(argv=None):
|
|
242
338
|
parser = build_parser()
|
|
243
339
|
args = parser.parse_args(argv)
|
|
244
340
|
|
|
@@ -246,41 +342,86 @@ def main(argv = None):
|
|
|
246
342
|
first_row = 0
|
|
247
343
|
if type != "youtube":
|
|
248
344
|
# Handle case when path is not provided (no subcommand)
|
|
249
|
-
if not hasattr(args,
|
|
250
|
-
print(
|
|
251
|
-
|
|
345
|
+
if not hasattr(args, "path"):
|
|
346
|
+
print(
|
|
347
|
+
"Error: No subcommand provided. Use --help to see available commands."
|
|
348
|
+
)
|
|
349
|
+
print(
|
|
350
|
+
"Available commands: scatter, plot, plotter, bar, hist, image, gif, video, youtube"
|
|
351
|
+
)
|
|
252
352
|
print("Example: plotext_plus scatter --path test")
|
|
253
353
|
return
|
|
254
|
-
|
|
354
|
+
|
|
255
355
|
path = args.path
|
|
256
356
|
first_row = args.first_row
|
|
257
|
-
clt =
|
|
357
|
+
clt = args.clear_terminal[-1] == "True"
|
|
258
358
|
sleep = args.sleep[0]
|
|
259
359
|
|
|
260
|
-
def
|
|
261
|
-
|
|
360
|
+
def get_x_y(data):
|
|
361
|
+
data_length = len(data)
|
|
262
362
|
xcol = args.xcolumn[0]
|
|
263
363
|
ycols = args.ycolumns
|
|
264
|
-
xcol =
|
|
265
|
-
|
|
266
|
-
|
|
364
|
+
xcol = (
|
|
365
|
+
"none"
|
|
366
|
+
if xcol == "none"
|
|
367
|
+
else int(xcol) if int(xcol) - 1 in range(data_length) else "none"
|
|
368
|
+
)
|
|
369
|
+
all_ycols = [el for el in range(data_length) if el != xcol]
|
|
370
|
+
ycols = (
|
|
371
|
+
all_ycols
|
|
372
|
+
if ycols == ["all"]
|
|
373
|
+
else [int(el) for el in ycols if int(el) - 1 in range(data_length)]
|
|
374
|
+
)
|
|
267
375
|
x = list(range(1, len(data[0]) + 1)) if xcol == "none" else data[xcol - 1]
|
|
268
|
-
|
|
269
|
-
return x,
|
|
270
|
-
|
|
271
|
-
def plot(x,
|
|
272
|
-
for y in
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
376
|
+
y_values = [data[i - 1] for i in ycols]
|
|
377
|
+
return x, y_values
|
|
378
|
+
|
|
379
|
+
def plot(x, y_values):
|
|
380
|
+
for y in y_values:
|
|
381
|
+
(
|
|
382
|
+
plt.plot(x, y, marker=marker, color=color)
|
|
383
|
+
if type in ["plot", "plotter"]
|
|
384
|
+
else None
|
|
385
|
+
)
|
|
386
|
+
(
|
|
387
|
+
plt.scatter(
|
|
388
|
+
x, y, marker=marker, color=None if type == "plotter" else color
|
|
389
|
+
)
|
|
390
|
+
if type in ["scatter", "plotter"]
|
|
391
|
+
else None
|
|
392
|
+
)
|
|
393
|
+
(
|
|
394
|
+
plt.bar(
|
|
395
|
+
x,
|
|
396
|
+
y,
|
|
397
|
+
marker=marker,
|
|
398
|
+
color=color,
|
|
399
|
+
width=width,
|
|
400
|
+
orientation=orientation,
|
|
401
|
+
fill=fill,
|
|
402
|
+
)
|
|
403
|
+
if type == "bar"
|
|
404
|
+
else None
|
|
405
|
+
)
|
|
406
|
+
(
|
|
407
|
+
plt.hist(
|
|
408
|
+
y,
|
|
409
|
+
marker=marker,
|
|
410
|
+
color=color,
|
|
411
|
+
orientation=orientation,
|
|
412
|
+
fill=fill,
|
|
413
|
+
bins=bins,
|
|
414
|
+
)
|
|
415
|
+
if type == "hist"
|
|
416
|
+
else None
|
|
417
|
+
)
|
|
277
418
|
plt.clt() if clt else None
|
|
278
419
|
plt.show()
|
|
279
420
|
plt.cld()
|
|
280
421
|
plt.sleep(sleep)
|
|
281
422
|
|
|
282
|
-
data_plot = [
|
|
283
|
-
test_path =
|
|
423
|
+
data_plot = ["scatter", "plot", "plotter", "bar", "hist"]
|
|
424
|
+
test_path = "test"
|
|
284
425
|
|
|
285
426
|
if type in data_plot:
|
|
286
427
|
lines = args.lines[0]
|
|
@@ -288,17 +429,17 @@ def main(argv = None):
|
|
|
288
429
|
title = args.title[0]
|
|
289
430
|
xlabel = args.xlabel[0]
|
|
290
431
|
ylabel = args.ylabel[0]
|
|
291
|
-
grid =
|
|
432
|
+
grid = args.grid[-1] == "True"
|
|
292
433
|
|
|
293
|
-
orientation = args.orientation[0] if type in [
|
|
294
|
-
fill = args.fill[0] ==
|
|
295
|
-
width = args.width[0]
|
|
296
|
-
bins = args.bins[0] if type in
|
|
434
|
+
orientation = args.orientation[0] if type in ["bar", "hist"] else "v"
|
|
435
|
+
fill = args.fill[0] == "True" if type in ["bar", "hist"] else False
|
|
436
|
+
width = args.width[0] if type == "bar" else 0
|
|
437
|
+
bins = args.bins[0] if type in "hist" else None
|
|
297
438
|
|
|
298
439
|
marker = args.marker[0]
|
|
299
440
|
color = args.color[0]
|
|
300
441
|
|
|
301
|
-
plt.title(title)
|
|
442
|
+
plt.title(title)
|
|
302
443
|
plt.xlabel(xlabel)
|
|
303
444
|
plt.ylabel(ylabel)
|
|
304
445
|
plt.grid(grid)
|
|
@@ -306,67 +447,68 @@ def main(argv = None):
|
|
|
306
447
|
if path == test_path:
|
|
307
448
|
plt.plotsize(None, plt.th() - 3)
|
|
308
449
|
if type != "bar":
|
|
309
|
-
plt.download(plt.test_data_url, test_path, log
|
|
450
|
+
plt.download(plt.test_data_url, test_path, log=True)
|
|
310
451
|
else:
|
|
311
|
-
plt.download(plt.test_bar_data_url, test_path, log
|
|
452
|
+
plt.download(plt.test_bar_data_url, test_path, log=True)
|
|
312
453
|
path = test_path
|
|
313
454
|
|
|
314
455
|
if path is None:
|
|
456
|
+
|
|
315
457
|
def plot_text(text):
|
|
316
|
-
data = plt._utility.read_lines(text, delimiter
|
|
458
|
+
data = plt._utility.read_lines(text, delimiter=delimiter)
|
|
317
459
|
data = plt.transpose(data)
|
|
318
|
-
x,
|
|
319
|
-
plot(x,
|
|
460
|
+
x, y_values = get_x_y(data)
|
|
461
|
+
plot(x, y_values)
|
|
320
462
|
|
|
321
463
|
for _ in range(first_row):
|
|
322
464
|
sys.stdin.readline()
|
|
323
465
|
text = []
|
|
324
|
-
|
|
325
|
-
for line in iter(sys.stdin.readline, ''):
|
|
466
|
+
for line in iter(sys.stdin.readline, ""):
|
|
326
467
|
text.append(line)
|
|
327
|
-
i+=1;
|
|
328
468
|
if len(text) == lines:
|
|
329
469
|
plot_text(text)
|
|
330
470
|
text = []
|
|
331
|
-
if
|
|
471
|
+
if (
|
|
472
|
+
len(text) > 0
|
|
473
|
+
): # this is when there is some residual data to be plotted, not lines long
|
|
332
474
|
plot_text(text)
|
|
333
475
|
text = []
|
|
334
476
|
|
|
335
477
|
else:
|
|
336
|
-
data = plt.read_data(path, delimiter
|
|
478
|
+
data = plt.read_data(path, delimiter=delimiter, first_row=first_row)
|
|
337
479
|
data = plt.transpose(data)
|
|
338
|
-
x,
|
|
480
|
+
x, y_values = get_x_y(data)
|
|
339
481
|
chunks = len(x) // lines + (1 if len(x) % lines else 0)
|
|
340
482
|
for c in range(chunks):
|
|
341
|
-
xc = x[c * lines: (c + 1) * lines]
|
|
342
|
-
|
|
343
|
-
plot(xc,
|
|
483
|
+
xc = x[c * lines : (c + 1) * lines]
|
|
484
|
+
y_chunk = [y[c * lines : (c + 1) * lines] for y in y_values]
|
|
485
|
+
plot(xc, y_chunk)
|
|
344
486
|
|
|
345
|
-
elif type ==
|
|
487
|
+
elif type == "image":
|
|
346
488
|
if path == test_path:
|
|
347
489
|
plt.plotsize(None, plt.th() - 3)
|
|
348
|
-
plt.download(plt.test_image_url, test_path, log
|
|
490
|
+
plt.download(plt.test_image_url, test_path, log=True)
|
|
349
491
|
path = test_path
|
|
350
|
-
plt.image_plot(path, fast
|
|
492
|
+
plt.image_plot(path, fast=True)
|
|
351
493
|
plt.clt() if clt else None
|
|
352
494
|
plt.show()
|
|
353
495
|
|
|
354
|
-
elif type ==
|
|
496
|
+
elif type == "gif":
|
|
355
497
|
if path == test_path:
|
|
356
498
|
plt.plotsize(None, plt.th() - 3)
|
|
357
|
-
plt.download(plt.test_gif_url, test_path, log
|
|
499
|
+
plt.download(plt.test_gif_url, test_path, log=True)
|
|
358
500
|
path = test_path
|
|
359
501
|
plt.play_gif(path)
|
|
360
502
|
|
|
361
|
-
elif type ==
|
|
503
|
+
elif type == "video":
|
|
362
504
|
if path == test_path:
|
|
363
505
|
plt.plotsize(None, plt.th() - 3)
|
|
364
|
-
plt.download(plt.test_video_url, test_path, log
|
|
506
|
+
plt.download(plt.test_video_url, test_path, log=True)
|
|
365
507
|
path = test_path
|
|
366
|
-
from_youtube =
|
|
508
|
+
from_youtube = args.from_youtube[-1] == "True"
|
|
367
509
|
plt.play_video(path, from_youtube)
|
|
368
510
|
|
|
369
|
-
elif type ==
|
|
511
|
+
elif type == "youtube":
|
|
370
512
|
url = args.url[-1]
|
|
371
513
|
url = plt.test_youtube_url if url == test_path else url
|
|
372
514
|
plt.play_youtube(url)
|
|
@@ -377,6 +519,3 @@ def main(argv = None):
|
|
|
377
519
|
|
|
378
520
|
if __name__ == "__main__":
|
|
379
521
|
sys.exit(main())
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|