Skip to content

Commit 243fc61

Browse files
committed
display_shapes example
1 parent 87d804b commit 243fc61

File tree

3 files changed

+69
-1
lines changed

3 files changed

+69
-1
lines changed

circuitpython_uplot/scatter.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,6 @@ def __init__(self, plot, x, y, radius=3):
5353
plot.append(
5454
Circle(pixel_shader=palette, radius=radius, x=xnorm[i], y=ynorm[i])
5555
)
56+
57+
if plot._showticks:
58+
plot._draw_ticks(x, y)

docs/examples.rst

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,27 @@ Setting up the ticks parameters
3434
Integration Example
3535
-------------------
3636

37-
Example showing different graphcals elements integration
37+
Example showing different graphics elements integration
3838

3939
.. literalinclude:: ../examples/uplot_integration_example.py
4040
:caption: examples/uplot_integration_example.py
4141
:linenos:
4242
.. image:: ../docs/uplot_ex5.jpg
43+
44+
Scatter Example
45+
-------------------
46+
47+
Scatter plot Example
48+
49+
.. literalinclude:: ../examples/uplot_scatter.py
50+
:caption: examples/uplot_scatter.py
51+
:linenos:
52+
53+
Display_shapes Example
54+
-----------------------
55+
56+
Display Shapes integration example
57+
58+
.. literalinclude:: ../examples/uplot_display_shapes.py
59+
:caption: examples/uplot_display_shapes.py
60+
:linenos:

examples/uplot_display_shapes.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2023 Jose D. Montoya
2+
#
3+
# SPDX-License-Identifier: Unlicense
4+
5+
import time
6+
import board
7+
from adafruit_display_shapes.polygon import Polygon
8+
from adafruit_display_shapes.roundrect import RoundRect
9+
from circuitpython_uplot.uplot import Uplot
10+
11+
# Setting up the display
12+
display = board.DISPLAY
13+
14+
plot = Uplot(0, 0, display.width, display.height)
15+
16+
# Setting up tick parameters
17+
plot.tick_params(tickheight=12, tickcolor=0xFF0008, tickgrid=True)
18+
plot.axs_params(axstype="box")
19+
plot.update_plot()
20+
21+
polygon = Polygon(
22+
[
23+
(255, 40),
24+
(262, 62),
25+
(285, 62),
26+
(265, 76),
27+
(275, 100),
28+
(255, 84),
29+
(235, 100),
30+
(245, 76),
31+
(225, 62),
32+
(248, 62),
33+
],
34+
outline=0x0000FF,
35+
)
36+
37+
roundrect = RoundRect(30, 30, 61, 81, 10, fill=0x0, outline=0xFF00FF, stroke=6)
38+
39+
plot.append(polygon)
40+
plot.append(roundrect)
41+
42+
# Plotting and showing the plot
43+
display.show(plot)
44+
45+
# Adding some wait time
46+
while True:
47+
time.sleep(1)

0 commit comments

Comments
 (0)