plotext-plus 1.0.8__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/_global.py CHANGED
@@ -1,47 +1,71 @@
1
1
  # This file contains some plotext functions which are only available to the top main level and not to sub figures (which are written in _figure.py and _monitor.py). These are functions which requires some coding and would be too long to be added directly in _core.py
2
2
 
3
- from plotext_plus._utility import marker_codes, hd_symbols, sin
4
- from plotext_plus._figure import _figure_class
5
- from plotext_plus._utility import themes as _themes
6
- import plotext_plus._utility as ut
7
- from time import time, sleep
8
- from math import sqrt, ceil
9
3
  import datetime as dt
4
+ from math import ceil
5
+ from math import sqrt
6
+ from time import sleep
7
+ from time import time
8
+
9
+ import plotext_plus._utility as ut
10
+ from plotext_plus._dict import hd_symbols
11
+ from plotext_plus._dict import marker_codes
12
+ from plotext_plus._dict import themes as _themes
13
+ from plotext_plus._figure import _FigureClass
10
14
 
11
- figure = _figure_class() # the main figure at top level
15
+ figure = _FigureClass() # the main figure at top level
12
16
 
13
17
  ##############################################
14
18
  ####### Simple Bar Functions ########
15
19
  ##############################################
16
20
 
17
- def simple_bar(*args, width = None, marker = None, color = None, title = None):
21
+
22
+ def simple_bar(*args, width=None, marker=None, color=None, title=None):
18
23
  x, y = ut.set_data(*args)
19
24
  marker = ut.correct_marker(marker)
20
25
 
21
26
  color_ok = ut.is_color(color) or (isinstance(color, list) and len(color) == len(x))
22
27
  color = [color] if color_ok else None
23
28
 
24
- simple_stacked_bar(x, [y], width = width, marker = marker, colors = color, title = title)
29
+ simple_stacked_bar(x, [y], width=width, marker=marker, colors=color, title=title)
30
+
25
31
 
26
- def simple_stacked_bar(*args, width = None, marker = None, colors = None, title = None, labels = None):
27
- x, y, Y, width = ut.bar_data(*args, width = width)
32
+ def simple_stacked_bar(
33
+ *args, width=None, marker=None, colors=None, title=None, labels=None
34
+ ):
35
+ x, y, y_scaled, width = ut.bar_data(*args, width=width)
28
36
  marker = ut.correct_marker(marker)
29
-
30
- bars = len(Y); stacked_bars = len(Y[0])
31
37
 
32
- colors_ok1 = isinstance(colors, list) and isinstance(colors[0], list) and ut.matrix_size(colors) == [bars, stacked_bars]
38
+ bars = len(y_scaled)
39
+ stacked_bars = len(y_scaled[0])
40
+
41
+ colors_ok1 = (
42
+ isinstance(colors, list)
43
+ and isinstance(colors[0], list)
44
+ and ut.matrix_size(colors) == [bars, stacked_bars]
45
+ )
33
46
  colors_ok2 = isinstance(colors, list) and len(colors) == stacked_bars
34
- colors = ut.transpose(colors) if colors_ok1 else [colors] * bars if colors_ok2 else [ut.color_sequence[:stacked_bars]] * bars
47
+ colors = (
48
+ ut.transpose(colors)
49
+ if colors_ok1
50
+ else (
51
+ [colors] * bars if colors_ok2 else [ut.color_sequence[:stacked_bars]] * bars
52
+ )
53
+ )
35
54
 
36
55
  title = ut.get_title(title, width)
37
- bars = [ut.single_bar(x[i], Y[i], y[i], marker, colors[i]) for i in range(bars)]
56
+ bars = [ut.single_bar(x[i], y_scaled[i], y[i], marker, colors[i]) for i in range(bars)]
38
57
  labels = ut.get_simple_labels(marker, labels, colors[0], width)
39
- figure.monitor.matrix.canvas = title + '\n'.join(bars) + labels
58
+ figure.monitor.matrix.canvas = title + "\n".join(bars) + labels
40
59
  figure.monitor.fast_plot = True
41
60
 
42
- def simple_multiple_bar(*args, width = None, marker = None, colors = None, title = None, labels = None):
43
- x, y, Y, width = ut.bar_data(*args, width = width, mode='multiple')
44
- bars = len(Y); multiple_bars = len(Y[0]); lx = len(x[0])
61
+
62
+ def simple_multiple_bar(
63
+ *args, width=None, marker=None, colors=None, title=None, labels=None
64
+ ):
65
+ x, y, y_scaled, width = ut.bar_data(*args, width=width, mode="multiple")
66
+ bars = len(y_scaled)
67
+ multiple_bars = len(y_scaled[0])
68
+ lx = len(x[0])
45
69
  marker = ut.correct_marker(marker)
46
70
 
47
71
  colors_ok = isinstance(colors, list) and len(colors) == multiple_bars
@@ -49,78 +73,94 @@ def simple_multiple_bar(*args, width = None, marker = None, colors = None, title
49
73
 
50
74
  out = ut.get_title(title, width)
51
75
  for i in range(bars):
52
- xn = [x[i] if j == (multiple_bars - 1) // 2 else ut.space * lx for j in range(multiple_bars)]
53
- new = [ut.single_bar(xn[j], [Y[i][j]], y[j][i], marker, [colors[j]]) for j in range(multiple_bars)]
54
- out += '\n'.join(new)
55
- out += '\n\n' if i != bars - 1 else ''
76
+ xn = [
77
+ x[i] if j == (multiple_bars - 1) // 2 else ut.space * lx
78
+ for j in range(multiple_bars)
79
+ ]
80
+ new = [
81
+ ut.single_bar(xn[j], [x[i][j]], y[j][i], marker, [colors[j]])
82
+ for j in range(multiple_bars)
83
+ ]
84
+ out += "\n".join(new)
85
+ out += "\n\n" if i != bars - 1 else ""
56
86
  labels = ut.get_simple_labels(marker, labels, colors, width)
57
87
  figure.monitor.matrix.canvas = out + labels
58
88
  figure.monitor.fast_plot = True
59
89
 
90
+
60
91
  ##############################################
61
92
  ############# Play GIF ################
62
93
  ##############################################
63
94
 
95
+
64
96
  def play_gif(path):
65
- from PIL import Image, ImageSequence
97
+ from PIL import Image
98
+ from PIL import ImageSequence
99
+
66
100
  path = ut.correct_path(path)
67
101
  if not ut.is_file(path):
68
102
  return
69
103
  im = Image.open(path)
70
- index = 1
71
104
  for image in ImageSequence.Iterator(im):
72
105
  load_time = time()
73
106
  figure.clt()
74
- image = image.convert('RGB')
75
- figure.monitor._draw_image(image, fast = True)
107
+ image = image.convert("RGB")
108
+ figure.monitor._draw_image(image, fast=True)
76
109
  figure.show()
77
110
  load_time = time() - load_time
78
- frame_time = image.info['duration'] / 10 ** 3
111
+ frame_time = image.info["duration"] / 10**3
79
112
  if load_time < frame_time:
80
113
  sleep(frame_time - load_time)
81
-
114
+
115
+
82
116
  ##############################################
83
117
  ########## Video Functions ############
84
118
  ##############################################
85
119
 
86
- def play_video(path, from_youtube = False):
120
+
121
+ def play_video(path, from_youtube=False):
87
122
  path = ut.correct_path(path)
88
123
  if not ut.is_file(path):
89
124
  return
90
125
  _play_video(path, from_youtube)
91
126
 
127
+
92
128
  def play_youtube(url):
93
129
  import pafy
130
+
94
131
  video = pafy.new(url)
95
132
  best = video.getbest()
96
- _play_video(best.url, from_youtube = True)
133
+ _play_video(best.url, from_youtube=True)
134
+
97
135
 
98
136
  def get_youtube(url, path, log):
99
137
  import pafy
138
+
100
139
  video = pafy.new(url)
101
- best = video.getbest(preftype = "mp4")
140
+ best = video.getbest(preftype="mp4")
102
141
  path = "youtube-video.mp4" if path is None else path
103
142
  path = ut.correct_path(path)
104
- best.download(filepath = path, quiet = not log)
105
- print(ut.format_strings('YouTube video downloaded as', path)) if log else None
143
+ best.download(filepath=path, quiet=not log)
144
+ print(ut.format_strings("YouTube video downloaded as", path)) if log else None
145
+
106
146
 
107
- def _play_video(path, from_youtube = False):
147
+ def _play_video(path, from_youtube=False):
108
148
  import cv2
109
149
  from ffpyplayer.player import MediaPlayer
110
150
  from PIL import Image
151
+
111
152
  cap = cv2.VideoCapture(path)
112
- player = MediaPlayer(path)#, paused = True, loglevel = 'quiet');
113
- fr = 0;
153
+ player = MediaPlayer(path) # , paused = True, loglevel = 'quiet');
154
+ fr = 0
114
155
  while fr == 0:
115
156
  fr = cap.get(cv2.CAP_PROP_FPS)
116
- frame_time = 1 / fr
117
- #to_list = lambda frame: [[tuple(int(el) for el in tup) for tup in row] for row in frame]
118
- pt = lambda time: '{time:05.1f} '.format(time=round(10 ** 3 * time, 1))
157
+ frame_time = 1 / fr
158
+ # to_list = lambda frame: [[tuple(int(el) for el in tup) for tup in row] for row in frame]
119
159
  real_time = video_time = 0
120
160
  while True:
121
161
  load_time = time()
122
- check_video, frame = cap.read();
123
- audio, check_audio = player.get_frame(show = False)
162
+ check_video, frame = cap.read()
163
+ audio, check_audio = player.get_frame(show=False)
124
164
  load_time = time() - load_time
125
165
  if not check_video:
126
166
  break
@@ -129,61 +169,73 @@ def _play_video(path, from_youtube = False):
129
169
  real_time += load_time
130
170
  video_time += frame_time
131
171
  show_time = 0
132
- shown = False
133
172
  if video_time >= real_time:
134
- shown = True
135
173
  show_time = time()
136
174
  frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB) if from_youtube else frame
137
- #frame = to_list(frame)
175
+ # frame = to_list(frame)
138
176
  image = Image.fromarray(frame)
139
-
177
+
140
178
  # Synchronized frame rendering - ensure each step completes before next
141
179
  figure.clt()
142
180
  # Small delay to ensure clear operation completes
143
181
  sleep(0.001) # 1ms delay
144
- figure.monitor._draw_image(image, fast = True)
182
+ figure.monitor._draw_image(image, fast=True)
145
183
  # Small delay to ensure image drawing completes before display
146
184
  sleep(0.001) # 1ms delay
147
185
  figure.show()
148
186
  # Brief delay after display to prevent frame overlap
149
187
  sleep(0.002) # 2ms delay for terminal rendering
150
-
188
+
151
189
  show_time = time() - show_time
152
190
  sleep_time = 0
153
191
  if real_time < video_time:
154
192
  sleep_time = time()
155
193
  sleep(video_time - real_time)
156
194
  sleep_time = time() - sleep_time
157
- total_time = load_time + show_time + sleep_time
195
+ load_time + show_time + sleep_time
158
196
  real_time += show_time + sleep_time
159
- #print('load: ' + pt(load_time), 'show: ' + pt(show_time), 'sleep: ' + pt(sleep_time), 'total: ' + pt(total_time), 'frame: ' + pt(frame_time), 'real: ' + pt(real_time), 'video: ' + pt(video_time), 'r/v:', round(real_time / video_time, 3)) if shown else None
197
+ # print('load: ' + pt(load_time), 'show: ' + pt(show_time), 'sleep: ' + pt(sleep_time), 'total: ' + pt(total_time), 'frame: ' + pt(frame_time), 'real: ' + pt(real_time), 'video: ' + pt(video_time), 'r/v:', round(real_time / video_time, 3)) if shown else None
160
198
  player.close_player()
161
199
  cap.release()
162
200
  cv2.destroyAllWindows()
163
201
  figure.clf()
164
202
 
203
+
165
204
  ##############################################
166
205
  ############ Utilities ###############
167
206
  ##############################################
168
207
 
169
- test_data_url = "https://raw.githubusercontent.com/piccolomo/plotext/master/data/data.txt"
170
- test_bar_data_url = "https://raw.githubusercontent.com/piccolomo/plotext/master/data/bar_data.txt"
171
- test_image_url = "https://raw.githubusercontent.com/piccolomo/plotext/master/data/cat.jpg"
172
- test_gif_url = "https://raw.githubusercontent.com/piccolomo/plotext/master/data/homer.gif"
173
- test_video_url = "https://raw.githubusercontent.com/piccolomo/plotext/master/data/moonwalk.mp4"
174
- test_youtube_url = 'https://www.youtube.com/watch?v=ZNAvVVc4b3E&t=75s'
208
+ test_data_url = (
209
+ "https://raw.githubusercontent.com/piccolomo/plotext/master/data/data.txt"
210
+ )
211
+ test_bar_data_url = (
212
+ "https://raw.githubusercontent.com/piccolomo/plotext/master/data/bar_data.txt"
213
+ )
214
+ test_image_url = (
215
+ "https://raw.githubusercontent.com/piccolomo/plotext/master/data/cat.jpg"
216
+ )
217
+ test_gif_url = (
218
+ "https://raw.githubusercontent.com/piccolomo/plotext/master/data/homer.gif"
219
+ )
220
+ test_video_url = (
221
+ "https://raw.githubusercontent.com/piccolomo/plotext/master/data/moonwalk.mp4"
222
+ )
223
+ test_youtube_url = "https://www.youtube.com/watch?v=ZNAvVVc4b3E&t=75s"
175
224
 
176
225
  ##############################################
177
226
  ######### Matplotlib Backend ##########
178
227
  ##############################################
179
228
 
180
- def from_matplotlib(fig, marker = None):
229
+
230
+ def from_matplotlib(fig, marker=None):
181
231
  fig.canvas.draw()
182
232
  slots = (rows, cols) = fig.axes[0].get_subplotspec().get_gridspec().get_geometry()
183
- figure.clf(); #clt()
233
+ figure.clf() # clt()
184
234
  figure.subplots(*slots)
185
- round10 = lambda data: [round(el, 10) for el in data]
186
- to_rgb = lambda rgb_norm: tuple([round(255 * el) for el in rgb_norm[:3]])
235
+ def round10(data):
236
+ return [round(el, 10) for el in data]
237
+ def to_rgb(rgb_norm):
238
+ return tuple([round(255 * el) for el in rgb_norm[:3]])
187
239
  figure.axes_color(to_rgb(fig.patch.get_facecolor()))
188
240
  for sub in fig.axes[:]:
189
241
  p = sub.get_subplotspec().get_geometry()[2]
@@ -200,20 +252,20 @@ def from_matplotlib(fig, marker = None):
200
252
  monitor.canvas_color(to_rgb(sub.get_facecolor()))
201
253
  for point in sub.collections:
202
254
  label = point.get_label()
203
- label = label if label[0] != '_' else ''
204
- #point.set_offset_position('data')
255
+ label = label if label[0] != "_" else ""
256
+ # point.set_offset_position('data')
205
257
  x, y = ut.transpose(point.get_offsets())
206
258
  color = [ut.to_rgb(point.to_rgba(el)) for el in point.get_facecolors()[0]]
207
259
  # can't find the right point colors
208
- monitor.scatter(x, y, label = label, marker = marker)
260
+ monitor.scatter(x, y, label=label, marker=marker)
209
261
  for line in sub.get_lines():
210
262
  label = line.get_label()
211
- label = label if label[0] != '_' else ''
263
+ label = label if label[0] != "_" else ""
212
264
  x, y = line.get_data()
213
- monitor.plot(x, y, marker = marker, color = line.get_c(), label = label)
265
+ monitor.plot(x, y, marker=marker, color=line.get_c(), label=label)
214
266
  for b in sub.patches:
215
267
  label = b.get_label()
216
- label = label if label[0] != '_' else ''
268
+ label = label if label[0] != "_" else ""
217
269
  color = b.get_facecolor()
218
270
  color = ut.to_rgb(color)
219
271
  box = b.get_bbox()
@@ -223,148 +275,194 @@ def from_matplotlib(fig, marker = None):
223
275
  fill = b.get_fill()
224
276
  fillx = fill if y0 == 0 else False
225
277
  filly = fill if x0 == 0 else False
226
- monitor.plot(x, y, fillx = fillx, filly = filly, marker = marker, color = color, label = label)
278
+ monitor.plot(
279
+ x, y, fillx=fillx, filly=filly, marker=marker, color=color, label=label
280
+ )
227
281
  monitor.xlim(*sub.get_xlim())
228
282
  monitor.ylim(*sub.get_ylim())
229
283
 
284
+
230
285
  ##############################################
231
286
  ####### Presentation Functions ########
232
287
  ##############################################
233
-
288
+
289
+
234
290
  def markers():
235
291
  markers = list(hd_symbols.keys())[::-1] + list(marker_codes.keys())
236
- l = len(markers)
237
- rows = int(sqrt(l))
238
- cols = ceil(l / rows)
292
+ marker_count = len(markers)
293
+ rows = int(sqrt(marker_count))
294
+ cols = ceil(marker_count / rows)
239
295
  y = ut.sin(1)
240
- figure.clf(); figure.theme('pro'); figure.xfrequency(0); figure.yfrequency(0); figure.frame(1)
296
+ figure.clf()
297
+ figure.theme("pro")
298
+ figure.xfrequency(0)
299
+ figure.yfrequency(0)
300
+ figure.frame(1)
241
301
  figure.subplots(rows, cols)
242
302
  figure.frame(0)
243
303
  for row in range(1, rows + 1):
244
304
  for col in range(1, cols + 1):
245
305
  i = (row - 1) * cols + col - 1
246
- if i < l:
306
+ if i < marker_count:
247
307
  subplot = figure.subplot(row, col)
248
308
  figure.frame(1)
249
- default = ' [default]' if markers[i] == 'hd' else ''
309
+ default = " [default]" if markers[i] == "hd" else ""
250
310
  subplot.title(markers[i] + default)
251
- subplot.scatter(y, marker = markers[i])
252
- subplot.ticks_style('bold')
253
- #figure.ticks_color(figure._utility.title_color)
311
+ subplot.scatter(y, marker=markers[i])
312
+ subplot.ticks_style("bold")
313
+ # figure.ticks_color(figure._utility.title_color)
254
314
  figure.show()
255
315
  figure.clf()
256
316
 
317
+
257
318
  def colors():
258
- print(ut.colorize("String Color Codes", style = 'bold'))
319
+ print(ut.colorize("String Color Codes", style="bold"))
259
320
  bg = "default"
260
- c = ut.no_duplicates([el.replace('+', '') for el in ut.colors if el not in ['default', 'black', 'white']])
261
- cp = [ut.colorize(ut.pad_string(el + '+', 10), el + '+', background = bg) for el in c]
262
- c = [ut.colorize(ut.pad_string(el, 10), el, background = bg) for el in c]
263
- c = [' ' + c[i] + cp[i] for i in range(len(c))]
264
- c = '\n'.join(c)
265
- print(' ' + ut.colorize(ut.pad_string('default', 20), background = bg))
266
- print(' ' + ut.colorize(ut.pad_string('black', 10), 'black', background = 'gray') + ut.colorize(ut.pad_string('white', 10), 'white', background = bg))
321
+ c = ut.no_duplicates(
322
+ [
323
+ el.replace("+", "")
324
+ for el in ut.colors
325
+ if el not in ["default", "black", "white"]
326
+ ]
327
+ )
328
+ cp = [ut.colorize(ut.pad_string(el + "+", 10), el + "+", background=bg) for el in c]
329
+ c = [ut.colorize(ut.pad_string(el, 10), el, background=bg) for el in c]
330
+ c = [" " + c[i] + cp[i] for i in range(len(c))]
331
+ c = "\n".join(c)
332
+ print(" " + ut.colorize(ut.pad_string("default", 20), background=bg))
333
+ print(
334
+ " "
335
+ + ut.colorize(ut.pad_string("black", 10), "black", background="gray")
336
+ + ut.colorize(ut.pad_string("white", 10), "white", background=bg)
337
+ )
267
338
  print(c)
268
339
  print()
269
- #print(colorize("\n\nInteger Color Codes:", style = ''))
270
- c = ut.colorize("Integer Color Codes", style = 'bold', show = False) + '\n'
340
+ # print(colorize("\n\nInteger Color Codes:", style = ''))
341
+ c = ut.colorize("Integer Color Codes", style="bold", show=False) + "\n"
271
342
  for row in range(16):
272
- cr = ' '
343
+ cr = " "
273
344
  for col in range(16):
274
345
  i = row * 16 + col
275
346
  cr += ut.colorize(ut.pad_string(i, 5), i)
276
- c += cr + '\n'
347
+ c += cr + "\n"
277
348
  print(c)
278
- c = '\n'
349
+ c = "\n"
279
350
  rgb = (100, 200, 85)
280
- rgb_string = '(' + ', '.join([str(el) for el in rgb]) + ')'
281
- print(ut.colorize("RGB Tuples like:", style = "bold"), ut.colorize(rgb_string, rgb, "bold"))
351
+ rgb_string = "(" + ", ".join([str(el) for el in rgb]) + ")"
352
+ print(
353
+ ut.colorize("RGB Tuples like:", style="bold"),
354
+ ut.colorize(rgb_string, rgb, "bold"),
355
+ )
356
+
282
357
 
283
358
  def styles():
284
- from plotext_plus._utility import styles, colorize, title_color
285
- c = [colorize(el, style = el) for el in styles]
286
- c = '\n'.join(c)
359
+ from plotext_plus._utility import colorize
360
+ from plotext_plus._utility import styles
361
+ from plotext_plus._utility import title_color
362
+
363
+ c = [colorize(el, style=el) for el in styles]
364
+ c = "\n".join(c)
287
365
  print(c)
288
- mul = 'bold italic dim'
289
- print('\n' + colorize('multiple styles are accepted, ', title_color) + 'eg: ' + colorize(mul, style = mul))
366
+ mul = "bold italic dim"
367
+ print(
368
+ "\n"
369
+ + colorize("multiple styles are accepted, ", title_color)
370
+ + "eg: "
371
+ + colorize(mul, style=mul)
372
+ )
373
+
290
374
 
291
375
  def themes():
292
376
  themes = list(_themes.keys())[::]
293
- l = len(themes)
294
- rows = int(sqrt(l))
295
- cols = ceil(l / rows)
296
- y1 = ut.sin(periods = 1)
297
- y2 = ut.sin(periods = 1, phase = -1)
377
+ theme_count = len(themes)
378
+ rows = int(sqrt(theme_count))
379
+ cols = ceil(theme_count / rows)
380
+ y1 = ut.sin(periods=1)
381
+ y2 = ut.sin(periods=1, phase=-1)
298
382
  figure.clf()
299
383
  figure.subplots(rows, cols)
300
384
  for row in range(1, rows + 1):
301
385
  for col in range(1, cols + 1):
302
386
  i = (row - 1) * cols + col - 1
303
- if i < l:
387
+ if i < theme_count:
304
388
  subplot = figure.subplot(row, col)
305
389
  subplot.theme(themes[i])
306
390
  subplot.title(themes[i])
307
- subplot.scatter(y1); subplot.plot(y2)
391
+ subplot.scatter(y1)
392
+ subplot.plot(y2)
308
393
  figure.show()
309
394
  figure.clf()
310
395
 
396
+
311
397
  ##############################################
312
398
  ########### Test Function #############
313
399
  ##############################################
314
400
 
401
+
315
402
  def test():
316
403
  import random
317
- figure.clf(); figure.clt()
318
- figure.date_form("d/m/Y");
404
+
405
+ figure.clf()
406
+ figure.clt()
407
+ figure.date_form("d/m/Y")
319
408
  figure.take_min()
320
409
  figure.plot_size(None, ut.terminal_height())
321
- #figure.plot_size(108, 70)
322
-
410
+ # figure.plot_size(108, 70)
411
+
323
412
  figure.plotsize(ut.tw(), ut.th() - 5)
324
413
  figure.subplots(2, 2)
325
-
414
+
326
415
  subplot = figure.subplot(1, 1)
327
416
  subplot.title("Multiple Axes Plot")
328
- subplot.canvas_color(66); subplot.axes_color(4); subplot.ticks_color(216); subplot.ticks_style('bold italic')
329
- y = ut.sin(periods = 1); l = len(y)
330
- subplot.scatter(y, label = "lower left")
331
- x = [figure.today_datetime() + dt.timedelta(days = i) for i in range(l)]; x = figure.datetimes_to_strings(x)
332
- subplot.plot(x, x, label = 'upper right - all dates', xside = 2, yside = 2)
333
- subplot.vline(l / 2, 'red')
417
+ subplot.canvas_color(66)
418
+ subplot.axes_color(4)
419
+ subplot.ticks_color(216)
420
+ subplot.ticks_style("bold italic")
421
+ y = ut.sin(periods=1)
422
+ data_length = len(y)
423
+ subplot.scatter(y, label="lower left")
424
+ x = [figure.today_datetime() + dt.timedelta(days=i) for i in range(data_length)]
425
+ x = figure.datetimes_to_strings(x)
426
+ subplot.plot(x, x, label="upper right - all dates", xside=2, yside=2)
427
+ subplot.vline(data_length / 2, "red")
334
428
  subplot.hline(0, 200)
335
- subplot.text("origin", l // 2, 0, color = 'red', alignment = 'center')
336
- subplot.xlabel('x lower'); subplot.xlabel('x upper', 2)
337
- subplot.ylabel('y left', 'left'); subplot.ylabel('y right', 'right')
338
- subplot.xfrequency(8); subplot.xfrequency(5, 2);
339
- subplot.yfrequency(3); subplot.yfrequency(5, 2);
340
- subplot.grid(1,1)
341
-
429
+ subplot.text("origin", data_length // 2, 0, color="red", alignment="center")
430
+ subplot.xlabel("x lower")
431
+ subplot.xlabel("x upper", 2)
432
+ subplot.ylabel("y left", "left")
433
+ subplot.ylabel("y right", "right")
434
+ subplot.xfrequency(8)
435
+ subplot.xfrequency(5, 2)
436
+ subplot.yfrequency(3)
437
+ subplot.yfrequency(5, 2)
438
+ subplot.grid(1, 1)
439
+
342
440
  subplot = figure.subplot(1, 2)
343
- subplot.theme('innocent')
441
+ subplot.theme("innocent")
344
442
  xb = ["Sausage", "Pepperoni", "Mushrooms", "Cheese", "Chicken", "Beef"]
345
443
  y1 = [36, 14, 11, 8, 7, 4]
346
444
  y2 = [20, 12, 35, 15, 4, 5]
347
- subplot.stacked_bar(xb, [y1, y2], labels = ["men", "women"])
445
+ subplot.stacked_bar(xb, [y1, y2], labels=["men", "women"])
348
446
 
349
447
  subplot = figure.subplot(2, 1)
350
- subplot.theme('dreamland')
351
- ld = 7 * 10 ** 4
448
+ subplot.theme("dreamland")
449
+ ld = 7 * 10**4
352
450
  data = [random.gauss(0, 1) for el in range(10 * ld)]
353
- subplot.hist(data, bins = 60, label="mean 0")
354
- subplot.frame(1); #subplot.xaxes(1, 0); subplot.yaxes(1, 0)
355
-
451
+ subplot.hist(data, bins=60, label="mean 0")
452
+ subplot.frame(1) # subplot.xaxes(1, 0); subplot.yaxes(1, 0)
453
+
356
454
  subplot = figure.subplot(2, 2)
357
- subplot.canvas_color('gray+'); subplot.axes_color('gray+')
358
- ut.download(test_image_url, 'cat.jpg')
359
- subplot.image_plot('cat.jpg', grayscale = False)
360
- ut.delete_file('cat.jpg')
361
- subplot.title('A very Cute Cat')
455
+ subplot.canvas_color("gray+")
456
+ subplot.axes_color("gray+")
457
+ ut.download(test_image_url, "cat.jpg")
458
+ subplot.image_plot("cat.jpg", grayscale=False)
459
+ ut.delete_file("cat.jpg")
460
+ subplot.title("A very Cute Cat")
362
461
  subplot.frame(0)
363
462
 
364
- #figure.plotsize(0, 0)
463
+ # figure.plotsize(0, 0)
365
464
  figure.show()
366
465
  figure._get_time()
367
- figure.save_fig('test.txt')
368
- figure.save_fig('test.html')
369
- #figure.clf()
370
-
466
+ figure.save_fig("test.txt")
467
+ figure.save_fig("test.html")
468
+ # figure.clf()