Skip to content

Commit 4186096

Browse files
committed
removing_examples_time
1 parent b04aa8f commit 4186096

22 files changed

+71
-155
lines changed

circuitpython_uplot/cartesian.py

Lines changed: 5 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ def __init__(
4040
rangey: Optional[list] = None,
4141
line_color: Optional[int] = None,
4242
line_style: Optional[str] = None,
43-
ticksx: Union[np.array, list] = np.array([0, 10, 30, 50, 70, 90]),
44-
ticksy: Union[np.array, list] = np.array([0, 10, 30, 50, 70, 90]),
43+
ticksx: Union[np.array, list] = None,
44+
ticksy: Union[np.array, list] = None,
4545
tick_pos: bool = False,
4646
fill: bool = False,
4747
nudge: bool = True,
@@ -65,8 +65,8 @@ def __init__(
6565
6666
"""
6767
self.points = []
68-
self.ticksx = np.array(ticksx)
69-
self.ticksy = np.array(ticksy)
68+
self.ticksx = ticksx
69+
self.ticksy = ticksy
7070

7171
if tick_pos:
7272
self._tickposx = plot._tickheightx
@@ -160,7 +160,7 @@ def __init__(
160160
if logging:
161161
x = np.linspace(self.xmin, self.xmax, 100)
162162
y = np.linspace(self.ymin, self.ymax, 100)
163-
self._draw_ticks(plot)
163+
plot._draw_ticks(x, y, self.ticksx, self.ticksy)
164164
plot._cartesianfirst = False
165165
plot._showticks = False
166166

@@ -193,54 +193,3 @@ def _plot_line(plot, index, xnorm, ynorm):
193193
ynorm[index + 1],
194194
plot._index_colorused,
195195
)
196-
197-
def _draw_ticks(self, plot) -> None:
198-
"""
199-
Draw ticks in the plot area
200-
201-
"""
202-
203-
ticksxnorm = np.array(
204-
plot.transform(
205-
self.xmin, self.xmax, plot._newxmin, plot._newxmax, self.ticksx
206-
),
207-
dtype=np.int16,
208-
)
209-
ticksynorm = np.array(
210-
plot.transform(
211-
self.ymin, self.ymax, plot._newymin, plot._newymax, self.ticksy
212-
),
213-
dtype=np.int16,
214-
)
215-
216-
for i, tick in enumerate(ticksxnorm):
217-
draw_line(
218-
plot._plotbitmap,
219-
tick,
220-
plot._newymin + self._tickposx,
221-
tick,
222-
plot._newymin - plot._tickheightx + self._tickposx,
223-
2,
224-
)
225-
if plot._showtext:
226-
plot.show_text(
227-
f"{self.ticksx[i]:.{plot._decimal_points}f}",
228-
tick,
229-
plot._newymin,
230-
(0.5, 0.0),
231-
)
232-
for i, tick in enumerate(ticksynorm):
233-
draw_line(
234-
plot._plotbitmap,
235-
plot._newxmin - self._tickposy,
236-
tick,
237-
plot._newxmin + plot._tickheighty - self._tickposy,
238-
tick,
239-
2,
240-
)
241-
if plot._showtext:
242-
plot.show_text(f"{self.ticksy[i]:.0f}", plot._newxmin, tick, (1.0, 0.5))
243-
244-
if plot._tickgrid:
245-
plot._draw_gridx(ticksxnorm)
246-
plot._draw_gridy(ticksynorm)

circuitpython_uplot/plot.py

Lines changed: 61 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ def transform(
270270
/ (oldrangemax - oldrangemin)
271271
) + newrangemin
272272

273-
def _draw_ticks(self, x: int, y: int) -> None:
273+
def _draw_ticks(self, x: int, y: int, ticksx=None, ticksy=None) -> None:
274274
"""
275275
Draw ticks in the plot area
276276
@@ -281,38 +281,58 @@ def _draw_ticks(self, x: int, y: int) -> None:
281281
282282
"""
283283

284-
ticks = np.array([10, 30, 50, 70, 90])
285-
subticks = np.array([20, 40, 60, 80])
286-
ticksxnorm = np.array(self.transform(0, 100, np.min(x), np.max(x), ticks))
287-
ticksynorm = np.array(self.transform(0, 100, np.min(y), np.max(y), ticks))
284+
ticks_dummy = np.array([10, 30, 50, 70, 90])
285+
subticks_dummy = np.array([20, 40, 60, 80])
286+
287+
if ticksx is None:
288+
ticksxnorm = np.array(
289+
self.transform(0, 100, np.min(x), np.max(x), ticks_dummy)
290+
)
291+
subticksxnorm = np.array(
292+
self.transform(0, 100, np.min(x), np.max(x), subticks_dummy)
293+
)
294+
else:
295+
ticksxnorm = np.array(ticksx)
296+
297+
if ticksy is None:
298+
ticksynorm = np.array(
299+
self.transform(0, 100, np.min(y), np.max(y), ticks_dummy)
300+
)
301+
subticksynorm = np.array(
302+
self.transform(0, 100, np.min(y), np.max(y), subticks_dummy)
303+
)
304+
else:
305+
ticksynorm = np.array(ticksy)
288306

289-
subticksxnorm = np.array(self.transform(0, 100, np.min(x), np.max(x), subticks))
290-
subticksynorm = np.array(self.transform(0, 100, np.min(y), np.max(y), subticks))
291307

292308
ticksxrenorm = np.array(
293309
self.transform(
294310
np.min(x), np.max(x), self._newxmin, self._newxmax, ticksxnorm
295311
),
296312
dtype=np.int16,
297313
)
314+
315+
298316
ticksyrenorm = np.array(
299317
self.transform(
300318
np.min(y), np.max(y), self._newymin, self._newymax, ticksynorm
301319
),
302320
dtype=np.int16,
303321
)
304-
subticksxrenorm = np.array(
305-
self.transform(
306-
np.min(x), np.max(x), self._newxmin, self._newxmax, subticksxnorm
307-
),
308-
dtype=np.int16,
309-
)
310-
subticksyrenorm = np.array(
311-
self.transform(
312-
np.min(y), np.max(y), self._newymin, self._newymax, subticksynorm
313-
),
314-
dtype=np.int16,
315-
)
322+
if ticksx is None:
323+
subticksxrenorm = np.array(
324+
self.transform(
325+
np.min(x), np.max(x), self._newxmin, self._newxmax, subticksxnorm
326+
),
327+
dtype=np.int16,
328+
)
329+
if ticksy is None:
330+
subticksyrenorm = np.array(
331+
self.transform(
332+
np.min(y), np.max(y), self._newymin, self._newymax, subticksynorm
333+
),
334+
dtype=np.int16,
335+
)
316336
for i, tick in enumerate(ticksxrenorm):
317337
draw_line(
318338
self._plotbitmap,
@@ -345,24 +365,28 @@ def _draw_ticks(self, x: int, y: int) -> None:
345365
tick,
346366
(1.0, 0.5),
347367
)
348-
for tick in subticksxrenorm:
349-
draw_line(
350-
self._plotbitmap,
351-
tick,
352-
self._newymin,
353-
tick,
354-
self._newymin - self._tickheightx // 2,
355-
2,
356-
)
357-
for tick in subticksyrenorm:
358-
draw_line(
359-
self._plotbitmap,
360-
self._newxmin,
361-
tick,
362-
self._newxmin + self._tickheighty // 2,
363-
tick,
364-
2,
365-
)
368+
369+
if ticksx is None:
370+
for tick in subticksxrenorm:
371+
draw_line(
372+
self._plotbitmap,
373+
tick,
374+
self._newymin,
375+
tick,
376+
self._newymin - self._tickheightx // 2,
377+
2,
378+
)
379+
380+
if ticksy is None:
381+
for tick in subticksyrenorm:
382+
draw_line(
383+
self._plotbitmap,
384+
self._newxmin,
385+
tick,
386+
self._newxmin + self._tickheighty // 2,
387+
tick,
388+
2,
389+
)
366390

367391
if self._tickgrid:
368392
self._draw_gridx(ticksxrenorm)

examples/bar_3Dbars.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,3 @@
2323

2424
# Plotting and showing the plot
2525
display.show(plot)
26-
27-
# Adding some wait time
28-
while True:
29-
time.sleep(1)

examples/bar_example.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,3 @@
2121

2222
# Plotting and showing the plot
2323
display.show(plot)
24-
25-
# Adding some wait time
26-
while True:
27-
time.sleep(1)

examples/bar_scale_example.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,3 @@
3131
group.append(plot_scale2)
3232

3333
display.show(group)
34-
35-
# Adding some wait time
36-
while True:
37-
time.sleep(1)

examples/cartesian_advanced.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,3 @@
2828

2929
# Plotting and showing the plot
3030
display.show(plot)
31-
32-
# Adding some wait time
33-
while True:
34-
time.sleep(1)

examples/display_shapes.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,3 @@
4343

4444
# Plotting and showing the plot
4545
display.show(plot)
46-
47-
# Adding some wait time
48-
while True:
49-
time.sleep(1)

examples/fillbetween.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,3 @@
2222
Fillbetween(plot, x, y1, y2)
2323

2424
display.show(plot)
25-
26-
# Adding some wait time
27-
while True:
28-
time.sleep(1)

examples/integration_example.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,3 @@
3232

3333
# Showing in the screen
3434
display.show(plot)
35-
36-
while True:
37-
pass

examples/logging_animation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
60,
1919
200,
2020
200,
21-
padding=1,
21+
padding=25,
2222
show_box=True,
2323
box_color=color.WHITE,
2424
)
@@ -78,7 +78,7 @@
7878
)
7979

8080
# Showing the loggraph
81-
while True:
81+
for _ in range(20):
8282
if dist > len(x):
8383
y.pop(0)
8484
y.append(random.choice(random_numbers))

0 commit comments

Comments
 (0)