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/_build.py CHANGED
@@ -1,24 +1,34 @@
1
1
  import plotext_plus._utility as ut
2
- import math
3
2
 
4
- # this file builds a class inherited by the monitor_class() in _monitor.py just because its only method - build_plot() - is very long and it is the core of plot building and it is written separately for clarity
3
+ # this file builds a class inherited by the MonitorClass() in _monitor.py just because its only method - build_plot() - is very long and it is the core of plot building and it is written separately for clarity
5
4
 
6
- class build_class():
7
-
8
- def build_plot(self): # it builds the plot given the external settings and internal settings collected in draw()
5
+
6
+ class BuildClass:
7
+
8
+ def build_plot(
9
+ self,
10
+ ): # it builds the plot given the external settings and internal settings collected in draw()
9
11
 
10
12
  # Initial Tools
11
13
  r2 = [0, 1]
12
- signals = len(self.x); Signals = list(range(signals))
13
- texts = len(self.text); Texts = list(range(texts))
14
+ signals = len(self.x)
15
+ signal_indices = list(range(signals))
16
+ texts = len(self.text)
17
+ text_indices = list(range(texts))
14
18
  width, height = self.size
15
19
  ticks_colors = self.ticks_color, self.ticks_style
16
20
 
17
21
  # Find if Axes are used
18
- xside = [(self.default.xside[i] in self.xside + self.txside) or self.vcoord[i] != [] for i in r2]
19
- yside = [(self.default.yside[i] in self.yside + self.tyside) or self.hcoord[i] != [] for i in r2]
20
-
21
- # Remove Useless X and Y Ticks and Labels if axes are not used
22
+ xside = [
23
+ (self.default.xside[i] in self.xside + self.txside) or self.vcoord[i] != []
24
+ for i in r2
25
+ ]
26
+ yside = [
27
+ (self.default.yside[i] in self.yside + self.tyside) or self.hcoord[i] != []
28
+ for i in r2
29
+ ]
30
+
31
+ # Remove Useless X and Y Ticks and Labels if axes are not used
22
32
  self.xticks = [self.xticks[i] if xside[i] else None for i in r2]
23
33
  self.xlabels = [self.xlabels[i] if xside[i] else None for i in r2]
24
34
 
@@ -32,66 +42,202 @@ class build_class():
32
42
  self.vcolors = [self.vcolors[i] if xside[i] else [] for i in r2]
33
43
 
34
44
  # Apply Scale (linear or log) to the data
35
- xscale = [ut.get_first(self.xscale, self.xside[s] is self.default.xside[0]) for s in Signals] # the x scale for each signal
36
- yscale = [ut.get_first(self.yscale, self.yside[s] is self.default.yside[0]) for s in Signals] # the y scale for each signal
37
- self.x = [ut.apply_scale(self.x[s], xscale[s] is self.default.xscale[1]) for s in Signals] # apply optional log scale
38
- self.y = [ut.apply_scale(self.y[s], yscale[s] is self.default.yscale[1]) for s in Signals]
45
+ xscale = [
46
+ ut.get_first(self.xscale, self.xside[s] is self.default.xside[0])
47
+ for s in signal_indices
48
+ ] # the x scale for each signal
49
+ yscale = [
50
+ ut.get_first(self.yscale, self.yside[s] is self.default.yside[0])
51
+ for s in signal_indices
52
+ ] # the y scale for each signal
53
+ self.x = [
54
+ ut.apply_scale(self.x[s], xscale[s] is self.default.xscale[1])
55
+ for s in signal_indices
56
+ ] # apply optional log scale
57
+ self.y = [
58
+ ut.apply_scale(self.y[s], yscale[s] is self.default.yscale[1])
59
+ for s in signal_indices
60
+ ]
39
61
 
40
62
  # Apply Scale (linear or log) to the Axes Ticks
41
- self.xticks = [ut.apply_scale(self.xticks[i], self.xscale[i] is self.default.xscale[1]) if self.xticks[i] is not None else None for i in r2] # apply optional log scale
42
- self.yticks = [ut.apply_scale(self.yticks[i], self.yscale[i] is self.default.yscale[1]) if self.yticks[i] is not None else None for i in r2] # apply optional log scale
43
-
63
+ self.xticks = [
64
+ (
65
+ ut.apply_scale(self.xticks[i], self.xscale[i] is self.default.xscale[1])
66
+ if self.xticks[i] is not None
67
+ else None
68
+ )
69
+ for i in r2
70
+ ] # apply optional log scale
71
+ self.yticks = [
72
+ (
73
+ ut.apply_scale(self.yticks[i], self.yscale[i] is self.default.yscale[1])
74
+ if self.yticks[i] is not None
75
+ else None
76
+ )
77
+ for i in r2
78
+ ] # apply optional log scale
79
+
44
80
  # Apply Scale (linear or log) to the user defined Lines
45
- self.hcoord = [ut.apply_scale(self.hcoord[i], self.yscale[i] is self.default.yscale[1]) for i in r2] # apply optional log scale
46
- self.vcoord = [ut.apply_scale(self.vcoord[i], self.xscale[i] is self.default.xscale[1]) for i in r2] # apply optional log scale
81
+ self.hcoord = [
82
+ ut.apply_scale(self.hcoord[i], self.yscale[i] is self.default.yscale[1])
83
+ for i in r2
84
+ ] # apply optional log scale
85
+ self.vcoord = [
86
+ ut.apply_scale(self.vcoord[i], self.xscale[i] is self.default.xscale[1])
87
+ for i in r2
88
+ ] # apply optional log scale
47
89
 
48
90
  # Apply Scale (linear or log) to the user defined Text
49
- txscale = [ut.get_first(self.xscale, self.txside[s] is self.default.xside[0]) for s in Texts] # the x scale for each text
50
- tyscale = [ut.get_first(self.yscale, self.tyside[s] is self.default.yside[0]) for s in Texts] # the y scale for each text
51
- self.tx = [ut.apply_scale([self.tx[s]], txscale[s] is self.default.xscale[1])[0] for s in Texts] #if width_canvas * height_canvas > 0 else [] # apply optional log scale
52
- self.ty = [ut.apply_scale([self.ty[s]], tyscale[s] is self.default.yscale[1])[0] for s in Texts] #if width_canvas * height_canvas > 0 else [] # apply optional log scale
53
- tx = [[self.tx[s] for s in Texts if self.txside[s] is self.default.xside[i]] for i in r2] # text x coord for each axis
54
- ty = [[self.ty[s] for s in Texts if self.tyside[s] is self.default.yside[i]] for i in r2] # text x coofor each axis
91
+ txscale = [
92
+ ut.get_first(self.xscale, self.txside[s] is self.default.xside[0])
93
+ for s in text_indices
94
+ ] # the x scale for each text
95
+ tyscale = [
96
+ ut.get_first(self.yscale, self.tyside[s] is self.default.yside[0])
97
+ for s in text_indices
98
+ ] # the y scale for each text
99
+ self.tx = [
100
+ ut.apply_scale([self.tx[s]], txscale[s] is self.default.xscale[1])[0]
101
+ for s in text_indices
102
+ ] # if width_canvas * height_canvas > 0 else [] # apply optional log scale
103
+ self.ty = [
104
+ ut.apply_scale([self.ty[s]], tyscale[s] is self.default.yscale[1])[0]
105
+ for s in text_indices
106
+ ] # if width_canvas * height_canvas > 0 else [] # apply optional log scale
107
+ tx = [
108
+ [self.tx[s] for s in text_indices if self.txside[s] is self.default.xside[i]]
109
+ for i in r2
110
+ ] # text x coord for each axis
111
+ ty = [
112
+ [self.ty[s] for s in text_indices if self.tyside[s] is self.default.yside[i]]
113
+ for i in r2
114
+ ] # text x coofor each axis
55
115
 
56
116
  # Get X Axes Limits
57
- x = [ut.join([self.x[s] for s in Signals if self.xside[s] is side]) for side in self.default.xside] # total x data for each axis
58
- x = [x[i] + self.vcoord[i] + tx[i] for i in r2] # add v lines and text coords to calculate xlim
117
+ x = [
118
+ ut.join([self.x[s] for s in signal_indices if self.xside[s] is side])
119
+ for side in self.default.xside
120
+ ] # total x data for each axis
121
+ x = [
122
+ x[i] + self.vcoord[i] + tx[i] for i in r2
123
+ ] # add v lines and text coords to calculate xlim
59
124
  xlim = [ut.get_lim(el) if len(el) > 0 else [None, None] for el in x]
60
125
  self.xlim = [ut.replace_none(self.xlim[i], xlim[i]) for i in r2]
61
- self.xlim = [self.xlim[i][:: self.xdirection[i]] for i in r2] # optionally reverse axes
62
- xlim = [self.xlim[0] if self.xside[s] == self.default.xside[0] else self.xlim[1] for s in Signals] # xlim for each signal
126
+ self.xlim = [
127
+ self.xlim[i][:: self.xdirection[i]] for i in r2
128
+ ] # optionally reverse axes
129
+ xlim = [
130
+ self.xlim[0] if self.xside[s] == self.default.xside[0] else self.xlim[1]
131
+ for s in signal_indices
132
+ ] # xlim for each signal
63
133
 
64
134
  # Get Y Axes Limits
65
- y = [ut.join([self.y[s] for s in Signals if self.yside[s] is side]) for side in self.default.yside]
66
- y = [y[i] + self.hcoord[i] + ty[i] for i in r2] # add h lines and text coords to calculate ylim
135
+ y = [
136
+ ut.join([self.y[s] for s in signal_indices if self.yside[s] is side])
137
+ for side in self.default.yside
138
+ ]
139
+ y = [
140
+ y[i] + self.hcoord[i] + ty[i] for i in r2
141
+ ] # add h lines and text coords to calculate ylim
67
142
  ylim = list(map(ut.get_lim, y))
68
143
  self.ylim = [ut.replace_none(self.ylim[i], ylim[i]) for i in r2]
69
- self.ylim = [self.ylim[i][:: self.ydirection[i]] for i in r2] # optionally reverse axes
70
- ylim = [self.ylim[0] if self.yside[s] == self.default.yside[0] else self.ylim[1] for s in Signals] # ylim for each signal
144
+ self.ylim = [
145
+ self.ylim[i][:: self.ydirection[i]] for i in r2
146
+ ] # optionally reverse axes
147
+ ylim = [
148
+ self.ylim[0] if self.yside[s] == self.default.yside[0] else self.ylim[1]
149
+ for s in signal_indices
150
+ ] # ylim for each signal
71
151
 
72
152
  # Get Y Ticks and Labels
73
- yticks_to_set = [self.yticks[i] is None and yside[i] and len(y[i]) > 0 for i in r2]
74
- yticks = [ut.linspace(*self.ylim[i], self.yfrequency[i]) if yticks_to_set[i] else self.yticks[i] for i in r2] # the actual Y ticks
75
- yticks_rescaled = [ut.reverse_scale(yticks[i], self.yscale[i] is self.default.yscale[1]) for i in r2]
76
-
77
- ylabels = [self.date.times_to_string(yticks_rescaled[i]) if self.y_date[i] else ut.get_labels(yticks_rescaled[i]) if yticks_to_set[i] else self.ylabels[i] for i in r2]
78
- ylabels = [ut.add_extra_spaces(ylabels[i], self.default.yside[i]) if ylabels[i] is not None else None for i in r2]
153
+ yticks_to_set = [
154
+ self.yticks[i] is None and yside[i] and len(y[i]) > 0 for i in r2
155
+ ]
156
+ yticks = [
157
+ (
158
+ ut.linspace(*self.ylim[i], self.yfrequency[i])
159
+ if yticks_to_set[i]
160
+ else self.yticks[i]
161
+ )
162
+ for i in r2
163
+ ] # the actual Y ticks
164
+ yticks_rescaled = [
165
+ ut.reverse_scale(yticks[i], self.yscale[i] is self.default.yscale[1])
166
+ for i in r2
167
+ ]
168
+
169
+ ylabels = [
170
+ (
171
+ self.date.times_to_string(yticks_rescaled[i])
172
+ if self.y_date[i]
173
+ else (
174
+ ut.get_labels(yticks_rescaled[i])
175
+ if yticks_to_set[i]
176
+ else self.ylabels[i]
177
+ )
178
+ )
179
+ for i in r2
180
+ ]
181
+ ylabels = [
182
+ (
183
+ ut.add_extra_spaces(ylabels[i], self.default.yside[i])
184
+ if ylabels[i] is not None
185
+ else None
186
+ )
187
+ for i in r2
188
+ ]
79
189
  width_ylabels = [ut.max_length(el) if el is not None else 0 for el in ylabels]
80
190
 
81
191
  # Get X Ticks and Labels
82
- xticks_to_set = [self.xticks[i] is None and xside[i] and len(x[i]) > 0 for i in r2]
83
- xticks = [ut.linspace(*self.xlim[i], self.xfrequency[i]) if xticks_to_set[i] else self.xticks[i] for i in r2] # the actual X ticks
84
- xticks_rescaled = [ut.reverse_scale(xticks[i], self.xscale[i] is self.default.xscale[1]) for i in r2]
85
- xlabels = [self.date.times_to_string(xticks_rescaled[i]) if self.x_date[i] else ut.get_labels(xticks_rescaled[i]) if xticks_to_set[i] else self.xlabels[i] for i in r2]
86
- xlabels = [ut.add_extra_spaces(xlabels[i], self.default.xside[i]) if xticks_to_set[i] else self.xlabels[i] for i in r2]
192
+ xticks_to_set = [
193
+ self.xticks[i] is None and xside[i] and len(x[i]) > 0 for i in r2
194
+ ]
195
+ xticks = [
196
+ (
197
+ ut.linspace(*self.xlim[i], self.xfrequency[i])
198
+ if xticks_to_set[i]
199
+ else self.xticks[i]
200
+ )
201
+ for i in r2
202
+ ] # the actual X ticks
203
+ xticks_rescaled = [
204
+ ut.reverse_scale(xticks[i], self.xscale[i] is self.default.xscale[1])
205
+ for i in r2
206
+ ]
207
+ xlabels = [
208
+ (
209
+ self.date.times_to_string(xticks_rescaled[i])
210
+ if self.x_date[i]
211
+ else (
212
+ ut.get_labels(xticks_rescaled[i])
213
+ if xticks_to_set[i]
214
+ else self.xlabels[i]
215
+ )
216
+ )
217
+ for i in r2
218
+ ]
219
+ xlabels = [
220
+ (
221
+ ut.add_extra_spaces(xlabels[i], self.default.xside[i])
222
+ if xticks_to_set[i]
223
+ else self.xlabels[i]
224
+ )
225
+ for i in r2
226
+ ]
87
227
  height_xlabels = [len(el) > 0 if el is not None else 0 for el in xlabels]
88
228
 
89
229
  # Canvas Dimensions (the area of data points)
90
230
  width_canvas = width - sum(self.yaxes) - sum(width_ylabels)
91
- height_highbar = any([el is not None for el in [self.title, self.xlabel[1]]])
92
- height_lowbar = any([el is not None for el in self.ylabel + [self.xlabel[0]]])
93
- height_canvas = height - sum(self.xaxes) - sum(height_xlabels) - height_highbar - height_lowbar
94
-
231
+ height_highbar = any(el is not None for el in [self.title, self.xlabel[1]])
232
+ height_lowbar = any(el is not None for el in self.ylabel + [self.xlabel[0]])
233
+ height_canvas = (
234
+ height
235
+ - sum(self.xaxes)
236
+ - sum(height_xlabels)
237
+ - height_highbar
238
+ - height_lowbar
239
+ )
240
+
95
241
  # Canvas Offset
96
242
  col_start = width_ylabels[0] + self.yaxes[0]
97
243
  col_end = col_start + width_canvas
@@ -99,22 +245,76 @@ class build_class():
99
245
  row_end = row_start + height_canvas
100
246
 
101
247
  # Get Absolute X and Y Ticks
102
- cticks = [ut.get_matrix_data(xticks[i], self.xlim[i], width_canvas) if xticks[i] != None else [] for i in r2]
103
- rticks = [ut.get_matrix_data(yticks[i], self.ylim[i], height_canvas) if yticks[i] != None else [] for i in r2]
104
-
105
- # Get Absolute Coordinates for user defined Lines
106
- hticks = [ut.get_matrix_data(self.hcoord[i], self.ylim[i], height_canvas) if None not in self.ylim[i] else [] for i in r2]
107
- vticks = [ut.get_matrix_data(self.vcoord[i], self.xlim[i], width_canvas) if None not in self.xlim[i] else [] for i in r2]
248
+ cticks = [
249
+ (
250
+ ut.get_matrix_data(xticks[i], self.xlim[i], width_canvas)
251
+ if xticks[i] is not None
252
+ else []
253
+ )
254
+ for i in r2
255
+ ]
256
+ rticks = [
257
+ (
258
+ ut.get_matrix_data(yticks[i], self.ylim[i], height_canvas)
259
+ if yticks[i] is not None
260
+ else []
261
+ )
262
+ for i in r2
263
+ ]
264
+
265
+ # Get Absolute Coordinates for user defined Lines
266
+ hticks = [
267
+ (
268
+ ut.get_matrix_data(self.hcoord[i], self.ylim[i], height_canvas)
269
+ if None not in self.ylim[i]
270
+ else []
271
+ )
272
+ for i in r2
273
+ ]
274
+ vticks = [
275
+ (
276
+ ut.get_matrix_data(self.vcoord[i], self.xlim[i], width_canvas)
277
+ if None not in self.xlim[i]
278
+ else []
279
+ )
280
+ for i in r2
281
+ ]
108
282
 
109
283
  # Get Absolute Coordinates for user defined Text
110
- txlim = [ut.get_first(self.xlim, self.txside[s] == self.default.xside[0]) for s in Texts] # xlim for each text
111
- tylim = [ut.get_first(self.ylim, self.tyside[s] == self.default.yside[0]) for s in Texts] # xlim for each text
112
- tcticks = [ut.get_matrix_data([self.tx[s]], txlim[s], width_canvas)[0] if width_canvas > 0 else 0 for s in Texts] #if width_canvas > 0 else [] #
113
- trticks = [ut.get_matrix_data([self.ty[s]], tylim[s], height_canvas)[0] if height_canvas > 0 else 0 for s in Texts] #if height_canvas > 0 else [] #
284
+ txlim = [
285
+ ut.get_first(self.xlim, self.txside[s] == self.default.xside[0])
286
+ for s in text_indices
287
+ ] # xlim for each text
288
+ tylim = [
289
+ ut.get_first(self.ylim, self.tyside[s] == self.default.yside[0])
290
+ for s in text_indices
291
+ ] # xlim for each text
292
+ tcticks = [
293
+ (
294
+ ut.get_matrix_data([self.tx[s]], txlim[s], width_canvas)[0]
295
+ if width_canvas > 0
296
+ else 0
297
+ )
298
+ for s in text_indices
299
+ ] # if width_canvas > 0 else [] #
300
+ trticks = [
301
+ (
302
+ ut.get_matrix_data([self.ty[s]], tylim[s], height_canvas)[0]
303
+ if height_canvas > 0
304
+ else 0
305
+ )
306
+ for s in text_indices
307
+ ] # if height_canvas > 0 else [] #
114
308
 
115
309
  # Get effective number of User Lines
116
- hlines = [len(el) for el in hticks]; Hlines = [list(range(el)) for el in hlines] # number of user defined horizontal lines for each y axis (as list)
117
- vlines = [len(el) for el in vticks]; Vlines = [list(range(el)) for el in vlines] # number of user defined vertical lines for each x axis (as list)
310
+ hlines = [len(el) for el in hticks]
311
+ hline_indices = [
312
+ list(range(el)) for el in hlines
313
+ ] # number of user defined horizontal lines for each y axis (as list)
314
+ vlines = [len(el) for el in vticks]
315
+ vline_indices = [
316
+ list(range(el)) for el in vlines
317
+ ] # number of user defined vertical lines for each x axis (as list)
118
318
 
119
319
  # Create Matrix of Markers
120
320
  self.matrix.set_size(width, height)
@@ -124,147 +324,563 @@ class build_class():
124
324
  self.matrix.set_matrices()
125
325
 
126
326
  # Add Title
127
- col_center = col_start + width_canvas // 2 # centered on the canvas not the entire plot
327
+ col_center = (
328
+ col_start + width_canvas // 2
329
+ ) # centered on the canvas not the entire plot
128
330
  col_title = col_center if self.xlabel[1] is None else 0
129
331
  row_title = row_end + self.xaxes[1] + height_xlabels[1]
130
332
  alignment_title = "center" if self.xlabel[1] is None else "left"
131
- self.matrix.add_horizontal_string(col_title, row_title, self.title, *ticks_colors, alignment = alignment_title, check_space = True) if self.title and height > 0 else None
333
+ (
334
+ self.matrix.add_horizontal_string(
335
+ col_title,
336
+ row_title,
337
+ self.title,
338
+ *ticks_colors,
339
+ alignment=alignment_title,
340
+ check_space=True,
341
+ )
342
+ if self.title and height > 0
343
+ else None
344
+ )
132
345
 
133
346
  # Add Upper X Label
134
- self.matrix.add_horizontal_string(col_center, row_title, self.xlabel[1], *ticks_colors, alignment = "center", check_space = True) if self.xlabel[1] and height > 0 else None
347
+ (
348
+ self.matrix.add_horizontal_string(
349
+ col_center,
350
+ row_title,
351
+ self.xlabel[1],
352
+ *ticks_colors,
353
+ alignment="center",
354
+ check_space=True,
355
+ )
356
+ if self.xlabel[1] and height > 0
357
+ else None
358
+ )
135
359
 
136
360
  # Add Lower X Ticks
137
361
  row_xticks = min(row_start - self.xaxes[0] - 1, height - 1)
138
- cticks_inserted = [height > 0 and self.matrix.add_horizontal_string(col_start + cticks[0][i], row_xticks, xlabels[0][i], *ticks_colors, alignment = "dynamic", check_space = True) for i in range(len(cticks[0]))]
139
- cticks[0] = [cticks[0][i] for i in range(len(cticks[0])) if cticks_inserted[i]] # it updates the x ticks coordinates whatever x labels were inserted
140
-
141
- # Add Upper X Ticks: the reason to do it here prematurely, is that the cticks[1] need to be re-evaluated for next step
362
+ cticks_inserted = [
363
+ height > 0
364
+ and self.matrix.add_horizontal_string(
365
+ col_start + cticks[0][i],
366
+ row_xticks,
367
+ xlabels[0][i],
368
+ *ticks_colors,
369
+ alignment="dynamic",
370
+ check_space=True,
371
+ )
372
+ for i in range(len(cticks[0]))
373
+ ]
374
+ cticks[0] = [
375
+ cticks[0][i] for i in range(len(cticks[0])) if cticks_inserted[i]
376
+ ] # it updates the x ticks coordinates whatever x labels were inserted
377
+
378
+ # Add Upper X Ticks: the reason to do it here prematurely, is that the cticks[1] need to be re-evaluated for next step
142
379
  row_xticks = row_end + self.xaxes[1]
143
- cticks_inserted = [height > 0 and self.matrix.add_horizontal_string(col_start + cticks[1][i], row_xticks, xlabels[1][i], *ticks_colors, alignment = "dynamic", check_space = True) for i in range(len(cticks[1]))]
144
- cticks[1] = [cticks[1][i] for i in range(len(cticks[1])) if cticks_inserted[i]] # it updates the x ticks coordinates whatever x labels were inserted
380
+ cticks_inserted = [
381
+ height > 0
382
+ and self.matrix.add_horizontal_string(
383
+ col_start + cticks[1][i],
384
+ row_xticks,
385
+ xlabels[1][i],
386
+ *ticks_colors,
387
+ alignment="dynamic",
388
+ check_space=True,
389
+ )
390
+ for i in range(len(cticks[1]))
391
+ ]
392
+ cticks[1] = [
393
+ cticks[1][i] for i in range(len(cticks[1])) if cticks_inserted[i]
394
+ ] # it updates the x ticks coordinates whatever x labels were inserted
145
395
 
146
396
  # Add Upper X Axes (from previous step)
147
- tick = lambda i: '┼' if (self.grid[1] and i in cticks[1]) else '┬' if (self.grid[1] and i in cticks[0] or i in ut.join(vticks)) else '┴' if i in cticks[1] else '─'
148
- xaxis = [tick(i) for i in range(width_canvas)]
149
- self.matrix.add_horizontal_string(col_start, row_end, xaxis, self.ticks_color) if self.xaxes[0] and height_canvas >= -1 else None
397
+ def get_upper_x_tick(i):
398
+ if self.grid[1] and i in cticks[1]:
399
+ return "┼"
400
+ elif self.grid[1] and i in cticks[0] or i in ut.join(vticks):
401
+ return "┬"
402
+ elif i in cticks[1]:
403
+ return "┴"
404
+ else:
405
+ return "─"
406
+
407
+ xaxis = [get_upper_x_tick(i) for i in range(width_canvas)]
408
+ (
409
+ self.matrix.add_horizontal_string(
410
+ col_start, row_end, xaxis, self.ticks_color
411
+ )
412
+ if self.xaxes[0] and height_canvas >= -1
413
+ else None
414
+ )
150
415
 
151
416
  # Add Left Y Ticks
152
- [self.matrix.add_horizontal_string(0, rticks[0][i] + row_start, ylabels[0][i], *ticks_colors) for i in range(len(rticks[0]))] if width >= width_ylabels[0] else None
153
-
417
+ (
418
+ [
419
+ self.matrix.add_horizontal_string(
420
+ 0, rticks[0][i] + row_start, ylabels[0][i], *ticks_colors
421
+ )
422
+ for i in range(len(rticks[0]))
423
+ ]
424
+ if width >= width_ylabels[0]
425
+ else None
426
+ )
427
+
154
428
  # Add Left Y Axis
155
- tick = lambda i: '┼' if (self.grid[0] and i in rticks[0]) else '├' if (self.grid[0] and i in rticks[1] or i in ut.join(hticks)) else '┤' if i in rticks[0] else '│'
156
- yaxis = [tick(i) for i in range(height_canvas)]
429
+ def get_left_y_tick(i):
430
+ if self.grid[0] and i in rticks[0]:
431
+ return "┼"
432
+ elif self.grid[0] and i in rticks[1] or i in ut.join(hticks):
433
+ return "├"
434
+ elif i in rticks[0]:
435
+ return "┤"
436
+ else:
437
+ return "│"
438
+
439
+ yaxis = [get_left_y_tick(i) for i in range(height_canvas)]
157
440
  col_yaxis = width_ylabels[0]
158
- self.matrix.add_vertical_string(col_yaxis, row_start, yaxis, self.ticks_color) if self.yaxes[0] and width >= sum(width_ylabels) + 1 else None
441
+ (
442
+ self.matrix.add_vertical_string(
443
+ col_yaxis, row_start, yaxis, self.ticks_color
444
+ )
445
+ if self.yaxes[0] and width >= sum(width_ylabels) + 1
446
+ else None
447
+ )
159
448
 
160
449
  # Add Right Y Axis
161
- tick = lambda i: '┼' if (self.grid[0] and i in rticks[1]) else '┤' if (self.grid[0] and i in rticks[0] or i in ut.join(hticks)) else '├' if i in rticks[1] else '│'
450
+ def tick(i):
451
+ return (
452
+ "┼"
453
+ if (self.grid[0] and i in rticks[1])
454
+ else (
455
+ "┤"
456
+ if (self.grid[0] and i in rticks[0] or i in ut.join(hticks))
457
+ else "├" if i in rticks[1] else "│"
458
+ )
459
+ )
162
460
  yaxis = [tick(i) for i in range(height_canvas)]
163
- self.matrix.add_vertical_string(col_end, row_start, yaxis, self.ticks_color) if self.yaxes[1] and width >= sum(width_ylabels) + self.yaxes[0] + 1 else None
461
+ (
462
+ self.matrix.add_vertical_string(col_end, row_start, yaxis, self.ticks_color)
463
+ if self.yaxes[1] and width >= sum(width_ylabels) + self.yaxes[0] + 1
464
+ else None
465
+ )
164
466
 
165
467
  # Add Right Y Ticks
166
- [self.matrix.add_horizontal_string(col_end + 1, rticks[1][i] + row_start, ylabels[1][i], *ticks_colors) for i in range(len(rticks[1]))] if width >= sum(width_ylabels) + 1 else None
468
+ (
469
+ [
470
+ self.matrix.add_horizontal_string(
471
+ col_end + 1, rticks[1][i] + row_start, ylabels[1][i], *ticks_colors
472
+ )
473
+ for i in range(len(rticks[1]))
474
+ ]
475
+ if width >= sum(width_ylabels) + 1
476
+ else None
477
+ )
167
478
 
168
479
  # Add Frame 4 Corners if necessary
169
480
  canvas_test = height_canvas >= 0 and width_canvas >= 0
170
- self.matrix.insert_element(col_start - 1, row_start - 1, '└', self.ticks_color) if self.xaxes[0] and self.yaxes[0] and canvas_test else None
171
- self.matrix.insert_element(col_end, row_start - 1, '┘', self.ticks_color) if self.xaxes[0] and self.yaxes[1] and canvas_test else None
172
- self.matrix.insert_element(col_start - 1, row_end, '┌', self.ticks_color) if self.xaxes[1] and self.yaxes[0] and canvas_test else None
173
- self.matrix.insert_element(col_end, row_end, '┐', self.ticks_color) if self.xaxes[1] and self.yaxes[1] and canvas_test else None
481
+ (
482
+ self.matrix.insert_element(
483
+ col_start - 1, row_start - 1, "└", self.ticks_color
484
+ )
485
+ if self.xaxes[0] and self.yaxes[0] and canvas_test
486
+ else None
487
+ )
488
+ (
489
+ self.matrix.insert_element(col_end, row_start - 1, "┘", self.ticks_color)
490
+ if self.xaxes[0] and self.yaxes[1] and canvas_test
491
+ else None
492
+ )
493
+ (
494
+ self.matrix.insert_element(col_start - 1, row_end, "┌", self.ticks_color)
495
+ if self.xaxes[1] and self.yaxes[0] and canvas_test
496
+ else None
497
+ )
498
+ (
499
+ self.matrix.insert_element(col_end, row_end, "┐", self.ticks_color)
500
+ if self.xaxes[1] and self.yaxes[1] and canvas_test
501
+ else None
502
+ )
174
503
 
175
504
  # Add Lower X Axes (from previous step)
176
- tick = lambda i: '┼' if (self.grid[1] and i in cticks[0]) else '┴' if (self.grid[1] and i in cticks[1] or i in ut.join(vticks)) else '┬' if i in cticks[0] else '─'
505
+ def tick(i):
506
+ return (
507
+ "┼"
508
+ if (self.grid[1] and i in cticks[0])
509
+ else (
510
+ "┴"
511
+ if (self.grid[1] and i in cticks[1] or i in ut.join(vticks))
512
+ else "┬" if i in cticks[0] else "─"
513
+ )
514
+ )
177
515
  xaxis = [tick(i) for i in range(width_canvas)]
178
- self.matrix.add_horizontal_string(col_start, row_start - 1, xaxis, self.ticks_color) if self.xaxes[0] and height_canvas >= -1 else None
516
+ (
517
+ self.matrix.add_horizontal_string(
518
+ col_start, row_start - 1, xaxis, self.ticks_color
519
+ )
520
+ if self.xaxes[0] and height_canvas >= -1
521
+ else None
522
+ )
179
523
 
180
524
  # Add Left Y Label
181
- self.matrix.add_horizontal_string(0, 0, self.ylabel[0], *ticks_colors, check_space = True) if self.ylabel[0] and height > 0 else None
182
-
183
- # Add Right Y Label
184
- self.matrix.add_horizontal_string(width - 1, 0, self.ylabel[1], *ticks_colors, check_space = True, alignment = "right") if self.ylabel[1] and height > 0 else None
185
-
186
- # Add Lower X Label
187
- self.matrix.add_horizontal_string(col_center, 0, self.xlabel[0], *ticks_colors, alignment = "center", check_space = True) if self.xlabel[0] and height > 0 else None
525
+ (
526
+ self.matrix.add_horizontal_string(
527
+ 0, 0, self.ylabel[0], *ticks_colors, check_space=True
528
+ )
529
+ if self.ylabel[0] and height > 0
530
+ else None
531
+ )
532
+
533
+ # Add Right Y Label
534
+ (
535
+ self.matrix.add_horizontal_string(
536
+ width - 1,
537
+ 0,
538
+ self.ylabel[1],
539
+ *ticks_colors,
540
+ check_space=True,
541
+ alignment="right",
542
+ )
543
+ if self.ylabel[1] and height > 0
544
+ else None
545
+ )
546
+
547
+ # Add Lower X Label
548
+ (
549
+ self.matrix.add_horizontal_string(
550
+ col_center,
551
+ 0,
552
+ self.xlabel[0],
553
+ *ticks_colors,
554
+ alignment="center",
555
+ check_space=True,
556
+ )
557
+ if self.xlabel[0] and height > 0
558
+ else None
559
+ )
188
560
 
189
561
  # Add Grid Lines
190
- hline = '' * width_canvas
191
- [self.matrix.add_horizontal_string(0 + col_start, row + row_start, hline, self.ticks_color) for row in ut.join(rticks) if self.grid[0]]
192
- vline = '│' * height_canvas
193
- [self.matrix.add_vertical_string(col + col_start, 0 + row_start, vline, self.ticks_color) for col in ut.join(cticks) if self.grid[1]]
194
- [self.matrix.insert_element(col + col_start, row + row_start, '┼') for row in ut.join(rticks) for col in ut.join(cticks) if all(self.grid)] # deals with the crossing between grids
195
-
562
+ hline = "" * width_canvas
563
+ [
564
+ self.matrix.add_horizontal_string(
565
+ 0 + col_start, row + row_start, hline, self.ticks_color
566
+ )
567
+ for row in ut.join(rticks)
568
+ if self.grid[0]
569
+ ]
570
+ vline = "│" * height_canvas
571
+ [
572
+ self.matrix.add_vertical_string(
573
+ col + col_start, 0 + row_start, vline, self.ticks_color
574
+ )
575
+ for col in ut.join(cticks)
576
+ if self.grid[1]
577
+ ]
578
+ [
579
+ self.matrix.insert_element(col + col_start, row + row_start, "┼")
580
+ for row in ut.join(rticks)
581
+ for col in ut.join(cticks)
582
+ if all(self.grid)
583
+ ] # deals with the crossing between grids
584
+
196
585
  # Add user defined Lines
197
- [[self.matrix.add_horizontal_string(col_start, hticks[i][l] + row_start, hline, self.hcolors[i][l]) for l in Hlines[i]] for i in r2]
198
- [[self.matrix.add_vertical_string(vticks[i][l] + col_start, 0 + row_start, vline, self.vcolors[i][l]) for l in Vlines[i]] for i in r2]
199
- [[[self.matrix.insert_element(col + col_start, hticks[i][l] + row_start, '┼', self.hcolors[i][l]) for l in Hlines[i]] for i in r2] for col in ut.join(cticks) if self.grid[1]] # deals with the crossing between h lines and v grids
200
- [[[self.matrix.insert_element(vticks[i][l] + col_start, row + row_start, '┼', self.vcolors[i][l]) for l in Vlines[i]] for i in r2] for row in ut.join(rticks) if self.grid[0]] # deals with the crossing between v lines and h grids
201
- [[[[self.matrix.insert_element(col_start + vticks[iv][lv], hticks[i][l] + row_start, '┼', self.hcolors[i][l]) for l in Hlines[i]] for i in r2] for lv in Vlines[iv]] for iv in r2] # deals with the crossing between h and v lines
586
+ [
587
+ [
588
+ self.matrix.add_horizontal_string(
589
+ col_start, hticks[i][line_idx] + row_start, hline, self.hcolors[i][line_idx]
590
+ )
591
+ for line_idx in hline_indices[i]
592
+ ]
593
+ for i in r2
594
+ ]
595
+ [
596
+ [
597
+ self.matrix.add_vertical_string(
598
+ vticks[i][line_idx] + col_start, 0 + row_start, vline, self.vcolors[i][line_idx]
599
+ )
600
+ for line_idx in vline_indices[i]
601
+ ]
602
+ for i in r2
603
+ ]
604
+ [
605
+ [
606
+ [
607
+ self.matrix.insert_element(
608
+ col + col_start,
609
+ hticks[i][line_idx] + row_start,
610
+ "┼",
611
+ self.hcolors[i][line_idx],
612
+ )
613
+ for line_idx in hline_indices[i]
614
+ ]
615
+ for i in r2
616
+ ]
617
+ for col in ut.join(cticks)
618
+ if self.grid[1]
619
+ ] # deals with the crossing between h lines and v grids
620
+ [
621
+ [
622
+ [
623
+ self.matrix.insert_element(
624
+ vticks[i][line_idx] + col_start,
625
+ row + row_start,
626
+ "┼",
627
+ self.vcolors[i][line_idx],
628
+ )
629
+ for line_idx in vline_indices[i]
630
+ ]
631
+ for i in r2
632
+ ]
633
+ for row in ut.join(rticks)
634
+ if self.grid[0]
635
+ ] # deals with the crossing between v lines and h grids
636
+ [
637
+ [
638
+ [
639
+ [
640
+ self.matrix.insert_element(
641
+ col_start + vticks[iv][lv],
642
+ hticks[i][line_idx] + row_start,
643
+ "┼",
644
+ self.hcolors[i][line_idx],
645
+ )
646
+ for line_idx in hline_indices[i]
647
+ ]
648
+ for i in r2
649
+ ]
650
+ for lv in vline_indices[iv]
651
+ ]
652
+ for iv in r2
653
+ ] # deals with the crossing between h and v lines
202
654
 
203
655
  # Expand Canvas to accommodate HD markers
204
- xf = [max([ut.marker_factor(el, 2, 2, 2) for el in self.marker[s]], default = 1) for s in Signals]
205
- yf = [max([ut.marker_factor(el, 2, 3, 4) for el in self.marker[s]], default = 1) for s in Signals]
656
+ xf = [
657
+ max([ut.marker_factor(el, 2, 2, 2) for el in self.marker[s]], default=1)
658
+ for s in signal_indices
659
+ ]
660
+ yf = [
661
+ max([ut.marker_factor(el, 2, 3, 4) for el in self.marker[s]], default=1)
662
+ for s in signal_indices
663
+ ]
206
664
  width_expanded = [width_canvas * el for el in xf]
207
665
  height_expanded = [height_canvas * el for el in yf]
208
666
 
209
667
  # Get Relative Data to Be Plotted on Matrix
210
- test_canvas = [width_expanded[s] * width_expanded[s] for s in Signals]
211
- x = [ut.get_matrix_data(self.x[s], xlim[s], width_expanded[s]) if test_canvas[s] else [] for s in Signals]
212
- y = [ut.get_matrix_data(self.y[s], ylim[s], height_expanded[s]) if test_canvas[s] else [] for s in Signals]
668
+ test_canvas = [width_expanded[s] * width_expanded[s] for s in signal_indices]
669
+ x = [
670
+ (
671
+ ut.get_matrix_data(self.x[s], xlim[s], width_expanded[s])
672
+ if test_canvas[s]
673
+ else []
674
+ )
675
+ for s in signal_indices
676
+ ]
677
+ y = [
678
+ (
679
+ ut.get_matrix_data(self.y[s], ylim[s], height_expanded[s])
680
+ if test_canvas[s]
681
+ else []
682
+ )
683
+ for s in signal_indices
684
+ ]
213
685
  m, c, st = self.marker, self.color, self.style
214
686
 
215
-
216
687
  # Add Lines between Data Points
217
- x, y, m, c, st = ut.transpose([ut.get_lines(x[s], y[s], m[s], c[s], st[s]) if self.lines[s] else (x[s], y[s], m[s], c[s], st[s]) for s in Signals], 5)
688
+ x, y, m, c, st = ut.transpose(
689
+ [
690
+ (
691
+ ut.get_lines(x[s], y[s], m[s], c[s], st[s])
692
+ if self.lines[s]
693
+ else (x[s], y[s], m[s], c[s], st[s])
694
+ )
695
+ for s in signal_indices
696
+ ],
697
+ 5,
698
+ )
218
699
 
219
700
  # Fillx
220
- #x, y, m, c, st = ut.transpose([ut.brush(x[s], y[s], m[s], c[s], st[s]) for s in Signals], 5)
221
- level = [ut.get_fill_level(self.fillx[s], ylim[s], height_expanded[s]) for s in Signals]
222
- x, y, m, c, st = ut.transpose([ut.fill_data(x[s], y[s], level[s], m[s], c[s], st[s]) if self.fillx[s] is not False else (x[s], y[s], m[s], c[s], st[s]) for s in Signals], 5)
223
-
701
+ # x, y, m, c, st = ut.transpose([ut.brush(x[s], y[s], m[s], c[s], st[s]) for s in signal_indices], 5)
702
+ level = [
703
+ ut.get_fill_level(self.fillx[s], ylim[s], height_expanded[s])
704
+ for s in signal_indices
705
+ ]
706
+ x, y, m, c, st = ut.transpose(
707
+ [
708
+ (
709
+ ut.fill_data(x[s], y[s], level[s], m[s], c[s], st[s])
710
+ if self.fillx[s] is not False
711
+ else (x[s], y[s], m[s], c[s], st[s])
712
+ )
713
+ for s in signal_indices
714
+ ],
715
+ 5,
716
+ )
717
+
224
718
  # Filly
225
- #x, y, m, c, st = ut.transpose([ut.brush(x[s], y[s], m[s], c[s], st[s]) for s in Signals], 5)
226
- level = [ut.get_fill_level(self.filly[s], xlim[s], width_expanded[s]) for s in Signals]
227
- y, x, m, c, st = ut.transpose([ut.fill_data(y[s], x[s], level[s], m[s], c[s], st[s]) if self.filly[s] is not False else (y[s], x[s], m[s], c[s], st[s]) for s in Signals], 5)
719
+ # x, y, m, c, st = ut.transpose([ut.brush(x[s], y[s], m[s], c[s], st[s]) for s in signal_indices], 5)
720
+ level = [
721
+ ut.get_fill_level(self.filly[s], xlim[s], width_expanded[s])
722
+ for s in signal_indices
723
+ ]
724
+ y, x, m, c, st = ut.transpose(
725
+ [
726
+ (
727
+ ut.fill_data(y[s], x[s], level[s], m[s], c[s], st[s])
728
+ if self.filly[s] is not False
729
+ else (y[s], x[s], m[s], c[s], st[s])
730
+ )
731
+ for s in signal_indices
732
+ ],
733
+ 5,
734
+ )
228
735
 
229
736
  # Get Actual HD Markers
230
- x, y, m, c, st = ut.transpose([ut.brush(x[s], y[s], m[s], c[s], st[s]) for s in Signals], 5)
231
- xf = [[ut.marker_factor(el, 2, 2, 2) for el in m[s]] for s in Signals]
232
- yf = [[ut.marker_factor(el, 2, 3, 4) for el in m[s]] for s in Signals]
233
- test = [max(xf[s], default = 1) * max(yf[s], default = 1) != 1 for s in Signals]
234
- x, y, mxy = ut.transpose([ut.hd_group(x[s], y[s], xf[s], yf[s]) if test[s] else (x[s], y[s], []) for s in Signals], 3)
235
- m = [[ut.get_hd_marker(mxy[s][i]) if m[s][i] in ut.hd_symbols else m[s][i] for i in range(len(x[s]))] for s in Signals]
737
+ x, y, m, c, st = ut.transpose(
738
+ [ut.brush(x[s], y[s], m[s], c[s], st[s]) for s in signal_indices], 5
739
+ )
740
+ xf = [[ut.marker_factor(el, 2, 2, 2) for el in m[s]] for s in signal_indices]
741
+ yf = [[ut.marker_factor(el, 2, 3, 4) for el in m[s]] for s in signal_indices]
742
+ test = [max(xf[s], default=1) * max(yf[s], default=1) != 1 for s in signal_indices]
743
+ x, y, mxy = ut.transpose(
744
+ [
745
+ ut.hd_group(x[s], y[s], xf[s], yf[s]) if test[s] else (x[s], y[s], [])
746
+ for s in signal_indices
747
+ ],
748
+ 3,
749
+ )
750
+ m = [
751
+ [
752
+ ut.get_hd_marker(mxy[s][i]) if m[s][i] in ut.hd_symbols else m[s][i]
753
+ for i in range(len(x[s]))
754
+ ]
755
+ for s in signal_indices
756
+ ]
236
757
 
237
758
  # Add Data to Canvas
238
- x, y, m, c, st = ut.transpose([ut.remove_outsiders(x[s], y[s], width_canvas, height_canvas, m[s], c[s], st[s]) for s in Signals], 5)
239
-
240
- x, y, m, c, st = ut.transpose([ut.brush(x[s], y[s], m[s], c[s], st[s]) for s in Signals], 5)
241
- [[self.matrix.insert_element(x[s][i] + col_start, y[s][i] + row_start, m[s][i], c[s][i], st[s][i]) for i in range(len(x[s]))] for s in Signals]
759
+ x, y, m, c, st = ut.transpose(
760
+ [
761
+ ut.remove_outsiders(
762
+ x[s], y[s], width_canvas, height_canvas, m[s], c[s], st[s]
763
+ )
764
+ for s in signal_indices
765
+ ],
766
+ 5,
767
+ )
768
+
769
+ x, y, m, c, st = ut.transpose(
770
+ [ut.brush(x[s], y[s], m[s], c[s], st[s]) for s in signal_indices], 5
771
+ )
772
+ [
773
+ [
774
+ self.matrix.insert_element(
775
+ x[s][i] + col_start, y[s][i] + row_start, m[s][i], c[s][i], st[s][i]
776
+ )
777
+ for i in range(len(x[s]))
778
+ ]
779
+ for s in signal_indices
780
+ ]
242
781
 
243
782
  # Legend Utilities
244
- labelled = lambda s: self.label[s] is not None
245
- labels = [ut.space + self.label[s] + ut.space for s in Signals if labelled(s)]; l = len(labels); L = ut.max_length(labels)
246
- labels = [el + ut.space * (L - len(el)) for el in labels]
783
+ def labelled(s):
784
+ return self.label[s] is not None
785
+ labels = [ut.space + self.label[s] + ut.space for s in signal_indices if labelled(s)]
786
+ label_count = len(labels)
787
+ max_label_length = ut.max_length(labels)
788
+ labels = [el + ut.space * (max_label_length - len(el)) for el in labels]
247
789
 
248
790
  # Add Legend Side Symbols
249
- side = [ut.space + ut.side_symbols[(self.xside[s], self.yside[s])] for s in Signals if labelled(s)]
250
- side_test = not (ut.no_duplicates(side) == [' L']) and not l == 1; S = 2 if side_test else 0;
251
- legend_test = width_canvas >= S + 3 + L and height_canvas >= len(labels)
252
- [self.matrix.add_horizontal_string(col_start, row_end - 1 - s, side[s], self.ticks_color, self.ticks_style) for s in range(l)] if legend_test and side_test else None
791
+ side = [
792
+ ut.space + ut.side_symbols[(self.xside[s], self.yside[s])]
793
+ for s in signal_indices
794
+ if labelled(s)
795
+ ]
796
+ side_test = ut.no_duplicates(side) != [" L"] and label_count != 1
797
+ side_width = 2 if side_test else 0
798
+ legend_test = width_canvas >= side_width + 3 + max_label_length and height_canvas >= len(labels)
799
+ (
800
+ [
801
+ self.matrix.add_horizontal_string(
802
+ col_start,
803
+ row_end - 1 - s,
804
+ side[s],
805
+ self.ticks_color,
806
+ self.ticks_style,
807
+ )
808
+ for s in range(label_count)
809
+ ]
810
+ if legend_test and side_test
811
+ else None
812
+ )
253
813
 
254
814
  # Add Legend Markers
255
- take_3 = lambda data: (data[ : 3] * 3)[ : 3]
256
- marker = [take_3(self.marker[s]) for s in Signals if labelled(s)]
257
- replace_hd_marker = lambda marker: ut.hd_symbols[marker] if marker in ut.hd_symbols else marker
815
+ def take_3(data):
816
+ return (data[:3] * 3)[:3]
817
+ marker = [take_3(self.marker[s]) for s in signal_indices if labelled(s)]
818
+ def replace_hd_marker(marker):
819
+ return (
820
+ ut.hd_symbols.get(marker, marker)
821
+ )
258
822
  marker = [[ut.space] + list(map(replace_hd_marker, el)) for el in marker]
259
- color = [[ut.no_color] + take_3(c[s]) for s in Signals if labelled(s)]
260
- style = [[ut.no_color] + take_3(st[s]) for s in Signals if labelled(s)]
261
- [[self.matrix.insert_element(col_start + S + i, row_end - 1 - s, marker[s][i], color[s][i], style[s][i]) for i in range(3)] for s in range(l)] if legend_test else None
262
- [self.matrix.add_horizontal_string(col_start + S + 3, row_end - 1 - s, labels[s], self.ticks_color, self.ticks_style) for s in range(l)] if legend_test else None
823
+ color = [[ut.no_color] + take_3(c[s]) for s in signal_indices if labelled(s)]
824
+ style = [[ut.no_color] + take_3(st[s]) for s in signal_indices if labelled(s)]
825
+ (
826
+ [
827
+ [
828
+ self.matrix.insert_element(
829
+ col_start + side_width + i,
830
+ row_end - 1 - s,
831
+ marker[s][i],
832
+ color[s][i],
833
+ style[s][i],
834
+ )
835
+ for i in range(3)
836
+ ]
837
+ for s in range(label_count)
838
+ ]
839
+ if legend_test
840
+ else None
841
+ )
842
+ (
843
+ [
844
+ self.matrix.add_horizontal_string(
845
+ col_start + side_width + 3,
846
+ row_end - 1 - s,
847
+ labels[s],
848
+ self.ticks_color,
849
+ self.ticks_style,
850
+ )
851
+ for s in range(label_count)
852
+ ]
853
+ if legend_test
854
+ else None
855
+ )
263
856
 
264
857
  # Add Text to Canvas
265
- [self.matrix.add_multiple_horizontal_strings(col_start + tcticks[s], row_start + trticks[s], self.text[s], self.tfull[s], self.tstyle[s], self.tback[s], self.talign[s], False, True) for s in Texts if self.torien[s] is self.default.orientation[0]]
266
- [self.matrix.add_multiple_vertical_strings(col_start + tcticks[s], row_start + trticks[s], self.text[s], self.tfull[s], self.tstyle[s], self.tback[s], self.talign[s], True) for s in Texts if self.torien[s] is self.default.orientation[1]]
267
-
268
-
269
-
270
-
858
+ [
859
+ self.matrix.add_multiple_horizontal_strings(
860
+ col_start + tcticks[s],
861
+ row_start + trticks[s],
862
+ self.text[s],
863
+ self.tfull[s],
864
+ self.tstyle[s],
865
+ self.tback[s],
866
+ self.talign[s],
867
+ False,
868
+ True,
869
+ )
870
+ for s in text_indices
871
+ if self.torien[s] is self.default.orientation[0]
872
+ ]
873
+ [
874
+ self.matrix.add_multiple_vertical_strings(
875
+ col_start + tcticks[s],
876
+ row_start + trticks[s],
877
+ self.text[s],
878
+ self.tfull[s],
879
+ self.tstyle[s],
880
+ self.tback[s],
881
+ self.talign[s],
882
+ True,
883
+ )
884
+ for s in text_indices
885
+ if self.torien[s] is self.default.orientation[1]
886
+ ]