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.
@@ -1,244 +1,340 @@
1
1
  #!/usr/bin/env python
2
- from plotext_plus._utility import all_markers, colors
3
- import argparse, sys, os
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
- # For Possible Colors and Markers Completion
11
- def dict_to_complete(d={}):
12
- return {'zsh': '((' + ' '.join(map(lambda x: str(x[0]) + '\\:' + x[1], d.items())) + '))'}
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 {'zsh': '((' + ' '.join([el + '\\:' for el in data]) + '))'}
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 = "plotext",
24
- description = "plotting directly on terminal",
25
- epilog = examples,
26
- formatter_class = argparse.RawDescriptionHelpFormatter)
27
- shtab.add_argument_to(parser, ["-s", "--print-completion"])
28
-
29
- parser.set_defaults(type = "scatter")
30
-
31
- path_parser = argparse.ArgumentParser(add_help = False)
32
-
33
- path_parser.add_argument("-p", "--path",
34
- action = 'store',
35
- #dest = 'path',
36
- type = str,
37
- metavar = "FILE",
38
- 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",
39
- ).complete = shtab.FILE
40
- path_parser.add_argument("-r", "--first-row",
41
- action = "store",
42
- type = int,
43
- default = 0,
44
- metavar = "FIRST-ROW",
45
- help = "The first line to consider in the data file (counting from 0).")
46
-
47
- common_parser = argparse.ArgumentParser(add_help = False)
48
-
49
- common_parser.add_argument("-clt", "--clear_terminal",
50
- nargs = 1,
51
- type = str,
52
- default = ["False"],
53
- choices = ["True", "False"],
54
- metavar = "BOOL",
55
- help = "it clears the terminal before plotting, if True (as by default)")
56
-
57
- common_parser.add_argument("-s", "--sleep",
58
- nargs = 1,
59
- type = float,
60
- default = [0],
61
- help = "it adds a sleeping time after plotting, to reduce flickering when multiple plots are required; 0 by default")
62
-
63
- data_parser = argparse.ArgumentParser(add_help = False)
64
-
65
- data_parser.add_argument("-xcol", "--xcolumn",
66
- nargs = "+", # 1 or more
67
- type = str,
68
- default = ["none"],
69
- help = "the column number (starting from 1), in the data table, that will be used as x data; by default 'none'")
70
-
71
- data_parser.add_argument("-ycols", "--ycolumns",
72
- nargs = "+", # 1 or more
73
- type = str,
74
- default = ["all"],
75
- help = "the column numbers (starting from 1), in the data table, that will be used as y data; by default 'all'")
76
-
77
- data_parser.add_argument("-d", "--delimiter",
78
- type = str,
79
- default = [' '],
80
- nargs = 1,
81
- help = "character to be used to separate columns in the data table (eg: ;); by default the white space ' '")
82
-
83
- data_parser.add_argument("-l", "--lines",
84
- nargs = "+", # 1 or more
85
- type = int,
86
- default = [1000],
87
- 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")
88
-
89
- options_parser = argparse.ArgumentParser(add_help = False)
90
-
91
- options_parser.add_argument("-m", "--marker",
92
- type = str,
93
- default = ['hd'],
94
- nargs = 1,
95
- choices = all_markers.keys(),
96
- metavar = "marker",
97
- help = "character or marker code identifying the data points in the plot, eg: x, braille, sd, heart, fhd; by default hd",
98
- ).complete = dict_to_complete(all_markers)
99
-
100
- options_parser.add_argument("-c", "--color",
101
- type = str,
102
- default = [None],
103
- nargs = 1,
104
- choices = colors,
105
- metavar = "COLOR",
106
- help = "color of the data points in the plot, between: " + ",".join(colors) + "; add + at the end of the color (except black and white) for clearer colors, eg: red+"
107
- ).complete = list_to_complete(colors)
108
-
109
- options_parser.add_argument("-t", "--title",
110
- nargs = 1,
111
- type = str,
112
- default = [None],
113
- help = "the plot title")
114
-
115
- options_parser.add_argument("-xl", "--xlabel",
116
- nargs = 1,
117
- type = str,
118
- default = [None],
119
- help = "the label of the x axis")
120
-
121
- options_parser.add_argument("-yl", "--ylabel",
122
- nargs = 1,
123
- type = str,
124
- default = [None],
125
- help = "the label of the y axis")
126
-
127
- options_parser.add_argument("-g", "--grid",
128
- nargs = 1,
129
- type = str,
130
- default = ["False"],
131
- choices = ["True", "False"],
132
- metavar = "BOOL",
133
- help = "it add grid lines if True, or removed them if False (as by default)")
134
-
135
- barhist_parser = argparse.ArgumentParser(add_help = False)
136
-
137
- barhist_parser.add_argument("-o", "--orientation",
138
- nargs = 1,
139
- type = str,
140
- default = ['v'],
141
- choices = ['v', 'h'],
142
- metavar = "ORIENTATION",
143
- help = "bar orientation, v for vertical (as by default), h for horizontal")
144
-
145
- barhist_parser.add_argument("-f", "--fill",
146
- nargs = 1,
147
- type = str,
148
- default = ["True"],
149
- choices = ["True", "False"],
150
- metavar = "BOOL",
151
- help = "it fills the bars with colored markers if True (as by default), otherwise only the bars skeleton is shown")
152
-
153
- subparser = parser.add_subparsers(dest = 'type',
154
- help = 'the user defined plot type')
155
-
156
- scatter = subparser.add_parser('scatter',
157
- description = "plots a series of data points",
158
- parents = [path_parser, data_parser, common_parser, options_parser],
159
- help = 'plots a series of data points',
160
- epilog = "eg: plotext scatter --path test --xcolumn 1 --ycolumns 2 --lines 5000 --title 'Scatter Plot Test' --marker braille")
161
-
162
-
163
- plot = subparser.add_parser('plot',
164
- parents = [path_parser, data_parser, common_parser, options_parser],
165
- description = "plots lines between consecutive data points",
166
- help = 'plots lines between consecutive data points',
167
- epilog = "eg: plotext plot --path test --xcolumn 1 --ycolumns 2 --sleep 0.1 --lines 2500 --clear_terminal True --color magenta+ --title 'Plot Test'")
168
-
169
- plotter = subparser.add_parser('plotter',
170
- parents = [path_parser, data_parser, common_parser, options_parser],
171
- description = 'plots a series of data points and the lines between consecutive ones',
172
- help = 'scatter + plot',
173
- epilog = "eg:plotext plotter --path test --xcolumn 1 --ycolumns 2 --sleep 0.1 --lines 120 --clear_terminal True --marker hd --title 'Plotter Test'")
174
-
175
- bar = subparser.add_parser('bar',
176
- parents = [path_parser, data_parser, common_parser, options_parser, barhist_parser],
177
- description = 'builds a bar plot',
178
- help = 'bar plot',
179
- epilog = "eg: plotext bar --path test --xcolumn 1 --title 'Bar Plot Test' --xlabel Animals --ylabel Count")
180
-
181
- bar.add_argument("-w", "--width",
182
- nargs = 1,
183
- type = float,
184
- default = [None],
185
- help = "bars width as a float between 0 and 1")
186
-
187
- hist = subparser.add_parser('hist',
188
- parents = [path_parser, data_parser, common_parser, options_parser, barhist_parser],
189
- description = 'builds a histogram plot',
190
- help = 'histogram plot',
191
- epilog = "eg: plotext hist --path test --xcolumn 1 --ycolumns 2 --lines 5000 --title 'Histogram Test'")
192
-
193
- hist.add_argument("-b", "--bins",
194
- nargs = 1,
195
- type = int,
196
- default = [10],
197
- help = "histogram bins (10 by default)")
198
-
199
- image = subparser.add_parser('image',
200
- parents = [path_parser, common_parser],
201
- description = 'plots an image from path',
202
- help = 'plots an image from file path',
203
- epilog = "eg: plotext image --path test")
204
-
205
- gif = subparser.add_parser('gif',
206
- parents = [path_parser, common_parser],
207
- description = 'plays a gif image from path',
208
- help = 'plays a gif image from path',
209
- epilog = "eg: plotext gif --path test")
210
-
211
- video = subparser.add_parser('video',
212
- parents = [path_parser, common_parser],
213
- description = 'plays a video from path',
214
- help = 'plays a video from path',
215
- epilog = "eg: plotext video --path test --from_youtube True")
216
-
217
- video.add_argument("-fy", "--from_youtube",
218
- nargs = 1,
219
- type = str,
220
- default = ["False"],
221
- choices = ["True", "False"],
222
- metavar = "BOOL",
223
- help = "set it to True to render the colors correctly for videos downloaded from youtube; default is False")
224
-
225
- youtube = subparser.add_parser('youtube',
226
- description = 'plays a youtube video from url',
227
- help = 'plays a youtube video from url',
228
- epilog = "eg: plotext youtube --url test")
229
-
230
- youtube.add_argument("-u", "--url",
231
- action = 'store',
232
- dest = 'url',
233
- nargs = 1,
234
- type = str,
235
- metavar = "URL",
236
- help = "the url of a youtube video; use 'test' for a test video")
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 = None):
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, 'path'):
250
- print("Error: No subcommand provided. Use --help to see available commands.")
251
- print("Available commands: scatter, plot, plotter, bar, hist, image, gif, video, youtube")
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 = True if args.clear_terminal[-1] == 'True' else False
357
+ clt = args.clear_terminal[-1] == "True"
258
358
  sleep = args.sleep[0]
259
359
 
260
- def get_xY(data):
261
- l = len(data)
360
+ def get_x_y(data):
361
+ data_length = len(data)
262
362
  xcol = args.xcolumn[0]
263
363
  ycols = args.ycolumns
264
- xcol = "none" if xcol == "none" else int(xcol) if int(xcol) - 1 in range(l) else "none"
265
- all_ycols = [el for el in range(l) if el != xcol]
266
- ycols = all_ycols if ycols == ["all"] else [int(el) for el in ycols if int(el) - 1 in range(l)]
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
- Y = [data[i - 1] for i in ycols]
269
- return x, Y
270
-
271
- def plot(x, Y):
272
- for y in Y:
273
- plt.plot(x, y, marker = marker, color = color) if type in ['plot', 'plotter'] else None
274
- plt.scatter(x, y, marker = marker, color = None if type == 'plotter' else color) if type in ['scatter', 'plotter'] else None
275
- plt.bar(x, y, marker = marker, color = color, width = width, orientation = orientation, fill = fill) if type == 'bar' else None
276
- plt.hist(y, marker = marker, color = color, orientation = orientation, fill = fill, bins = bins) if type == 'hist' else None
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 = ['scatter', 'plot', 'plotter', 'bar', 'hist']
283
- test_path = 'test'
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 = True if args.grid[-1] == 'True' else False
432
+ grid = args.grid[-1] == "True"
292
433
 
293
- orientation = args.orientation[0] if type in ['bar', 'hist'] else 'v'
294
- fill = args.fill[0] == 'True' if type in ['bar', 'hist'] else False
295
- width = args.width[0] if type == 'bar' else 0
296
- bins = args.bins[0] if type in 'hist' else None
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 = True)
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 = True)
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 = delimiter)
458
+ data = plt._utility.read_lines(text, delimiter=delimiter)
317
459
  data = plt.transpose(data)
318
- x, Y = get_xY(data)
319
- plot(x, Y)
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
- i = 0
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 len(text) > 0: # this is when there is some residual data to be plotted, not lines long
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 = delimiter, first_row = first_row)
478
+ data = plt.read_data(path, delimiter=delimiter, first_row=first_row)
337
479
  data = plt.transpose(data)
338
- x, Y = get_xY(data)
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
- Yc = [y[c * lines: (c + 1) * lines] for y in Y]
343
- plot(xc, Yc)
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 == 'image':
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 = True)
490
+ plt.download(plt.test_image_url, test_path, log=True)
349
491
  path = test_path
350
- plt.image_plot(path, fast = True)
492
+ plt.image_plot(path, fast=True)
351
493
  plt.clt() if clt else None
352
494
  plt.show()
353
495
 
354
- elif type == 'gif':
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 = True)
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 == 'video':
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 = True)
506
+ plt.download(plt.test_video_url, test_path, log=True)
365
507
  path = test_path
366
- from_youtube = True if args.from_youtube[-1] == 'True' else False
508
+ from_youtube = args.from_youtube[-1] == "True"
367
509
  plt.play_video(path, from_youtube)
368
510
 
369
- elif type == 'youtube':
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
-