diff --git a/circuitpython_uplot/scatter.py b/circuitpython_uplot/scatter.py index 562903d..2506861 100644 --- a/circuitpython_uplot/scatter.py +++ b/circuitpython_uplot/scatter.py @@ -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) diff --git a/docs/examples.rst b/docs/examples.rst index 5895eab..4f06093 100644 --- a/docs/examples.rst +++ b/docs/examples.rst @@ -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: diff --git a/examples/uplot_display_shapes.py b/examples/uplot_display_shapes.py new file mode 100644 index 0000000..bcbbd9f --- /dev/null +++ b/examples/uplot_display_shapes.py @@ -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)