Skip to content

Commit

Permalink
display_shapes example
Browse files Browse the repository at this point in the history
  • Loading branch information
jposada202020 committed Feb 12, 2023
1 parent 87d804b commit 243fc61
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 1 deletion.
3 changes: 3 additions & 0 deletions circuitpython_uplot/scatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,6 @@ def __init__(self, plot, x, y, radius=3):
plot.append(
Circle(pixel_shader=palette, radius=radius, x=xnorm[i], y=ynorm[i])
)

if plot._showticks:
plot._draw_ticks(x, y)
20 changes: 19 additions & 1 deletion docs/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,27 @@ Setting up the ticks parameters
Integration Example
-------------------

Example showing different graphcals elements integration
Example showing different graphics elements integration

.. literalinclude:: ../examples/uplot_integration_example.py
:caption: examples/uplot_integration_example.py
:linenos:
.. image:: ../docs/uplot_ex5.jpg

Scatter Example
-------------------

Scatter plot Example

.. literalinclude:: ../examples/uplot_scatter.py
:caption: examples/uplot_scatter.py
:linenos:

Display_shapes Example
-----------------------

Display Shapes integration example

.. literalinclude:: ../examples/uplot_display_shapes.py
:caption: examples/uplot_display_shapes.py
:linenos:
47 changes: 47 additions & 0 deletions examples/uplot_display_shapes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# SPDX-FileCopyrightText: Copyright (c) 2023 Jose D. Montoya
#
# SPDX-License-Identifier: Unlicense

import time
import board
from adafruit_display_shapes.polygon import Polygon
from adafruit_display_shapes.roundrect import RoundRect
from circuitpython_uplot.uplot import Uplot

# Setting up the display
display = board.DISPLAY

plot = Uplot(0, 0, display.width, display.height)

# Setting up tick parameters
plot.tick_params(tickheight=12, tickcolor=0xFF0008, tickgrid=True)
plot.axs_params(axstype="box")
plot.update_plot()

polygon = Polygon(
[
(255, 40),
(262, 62),
(285, 62),
(265, 76),
(275, 100),
(255, 84),
(235, 100),
(245, 76),
(225, 62),
(248, 62),
],
outline=0x0000FF,
)

roundrect = RoundRect(30, 30, 61, 81, 10, fill=0x0, outline=0xFF00FF, stroke=6)

plot.append(polygon)
plot.append(roundrect)

# Plotting and showing the plot
display.show(plot)

# Adding some wait time
while True:
time.sleep(1)

0 comments on commit 243fc61

Please sign in to comment.