Skip to content

Commit b3340d1

Browse files
committed
updating docs
1 parent e633c29 commit b3340d1

File tree

4 files changed

+65
-21
lines changed

4 files changed

+65
-21
lines changed

circuitpython_uplot/scatter.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,3 +173,14 @@ def _draw_pointer(self, plot: Plot) -> None:
173173
y=self._ynorm[i],
174174
)
175175
)
176+
177+
178+
class Pointer:
179+
"""
180+
Pointer container class
181+
"""
182+
183+
CIRCLE = "circle"
184+
TRIANGLE = "triangle"
185+
SQUARE = "square"
186+
DIAMOND = "diamond"

docs/quick_start.rst

Lines changed: 48 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -273,9 +273,9 @@ This can be done by importing the color class, from the cartesian library:
273273

274274
.. code-block:: python
275275
276-
from circuitpython_uplot.plot import LineStyle
276+
from circuitpython_uplot.cartesian import LineStyle
277277
278-
You could select a dotted line by using the following code: ``line_style=LineStyle.DOTTED``.
278+
You can select a dotted line by using the following code: ``line_style=LineStyle.DOTTED``.
279279

280280
.. code-block:: python
281281
@@ -328,7 +328,8 @@ Creates a scatter plot with x,y data. You can customize the circle diameter if y
328328
There are some parameters that you can customize:
329329
* rangex and rangey: you can specify the ranges of your graph. This allows you to move your graph according to your needs. This parameters only accept lists
330330
* radius: circles radius/radii. If a different value is given for each point, the radius should be a list of values. If selected pointer is not a circle, this parameter will be ignored
331-
* pointer_color: you can specify the color in HEX
331+
* pointer_color: you can specify the color in HEX. Or you could use the color class as explained above.
332+
* pointer: you can select the pointer shape. The default is a circle. See below for more details
332333
* nudge: this parameter allows you to move the graph slighty. This is useful when the data start/end in the limits of your range
333334

334335

@@ -340,12 +341,33 @@ There are some parameters that you can customize:
340341
b = [choice(a) for _ in a]
341342
Scatter(plot, a, b, rangex=[0,210], rangey=[0, 210], radius=radi, pointer_color=0xF456F3)
342343
344+
345+
Pointer styles
346+
==============
347+
You can select the pointer style of your Scatter graph. The following pointer styles are available:
348+
* Pointer.CIRCLE
349+
* Pointer.SQUARE
350+
* Pointer.TRIANGLE
351+
* Pointer.DIAMOND
352+
353+
This can be done by importing the color class, from the cartesian library:
354+
355+
.. code-block:: python
356+
357+
from circuitpython_uplot.scatter import Pointer
358+
359+
You can select a square pointer using the following code: ``pointer=Pointer.SQUARE``.
360+
361+
.. code-block:: python
362+
363+
Scatter(plot, a, b, pointer=Pointer.SQUARE)
364+
343365
===============
344366
Bar Plot
345367
===============
346368

347369
Allows you to graph bar plots. You just need to give the values of the bar in a python list.
348-
You can choose to create shell or filled bars.
370+
You can choose to create shell or filled bars or 3D projected bars.
349371

350372
.. code-block:: python
351373
@@ -362,21 +384,21 @@ You can choose to create shell or filled bars.
362384
Bar(plot, a, b)
363385
364386
365-
You can select the color or and if the bars are filled
387+
You can select the color or/and if the bars are filled
366388

367389
.. code-block:: python
368390
369-
Bar(plot, a, b, 0xFF1000, True)
391+
Bar(plot, a, b, color=0xFF1000, fill=True)
370392
371393
372394
You can also select the bar spacing and the xstart position:
373395

374396
.. code-block:: python
375397
376-
Bar(plot, a, b, 0xFF1000, fill=True, bar_space=30, xstart=70)
398+
Bar(plot, a, b, color=0xFF1000, fill=True, bar_space=30, xstart=70)
377399
378400
For bar filled graphs you can pass a color_palette list. This will allow you to select the color of each bar
379-
This will not work for shell bars sadly.
401+
This will not work for shell bars.
380402

381403
.. code-block:: python
382404
@@ -389,7 +411,7 @@ This will not work for shell bars sadly.
389411
Bar(plot, a, b, fill=True, bar_space=30, xstart=70, color_palette=[0xFF1000, 0x00FF00, 0x0000FF, 0x00FFFF])
390412
391413
392-
with the projection argument you can show the bars with projection. This will give them a 3D
414+
With the projection argument you can show the bars with projection. This will give them a 3D
393415
appearance
394416

395417
.. code-block:: python
@@ -407,7 +429,7 @@ appearance
407429
Bar(plot, a, b, color=0xFF1000, fill=True, bar_space=30, xstart=70, projection=True)
408430
409431
410-
For filled unprojected bars you can update their values. This is useful for data logging.
432+
For filled unprojected bars you can update their values in real time. This is useful for data logging.
411433
The max_value argument will allow you to set the maximum value of the graph. The plot will scale
412434
according to this max value, and bar plot will update their values accordingly
413435

@@ -425,7 +447,7 @@ according to this max value, and bar plot will update their values accordingly
425447
b = [3, 5, 1, 7]
426448
my_bar = Bar(plot, a, b, color=0xFF1000, fill=True, color_palette=[0xFF1000, 0x00FF00, 0xFFFF00, 0x123456], max_value=10)
427449
428-
Then you can update the values of the bar plot:
450+
Then you can update the values of the bar plot in a loop:
429451

430452
.. code-block:: python
431453
@@ -439,15 +461,12 @@ code will change all the bar's color to red
439461
440462
my_bar.update_colors(0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000)
441463
442-
If you prefer, you can change the color of a single bar using the following code:
464+
If you prefer, you can change the color of a single bar using the code below that will change the first bar to Blue.:
443465

444466
.. code-block:: python
445467
446468
my_bar.update_bar_color(0, 0x0000FF)
447469
448-
This will change the first bar to Blue.
449-
450-
451470
452471
===============
453472
Fillbetween
@@ -567,3 +586,17 @@ For example, if you want to load the Temperature icon with a scale of 2
567586
plot = Plot(0, 0, display.width, display.height)
568587
SVG(plot, Temperature, 250, 50, 2)
569588
display.show(plot)
589+
590+
===============
591+
SHADE
592+
===============
593+
Shade is a small module to add a shaded area to the plot. This is useful to highlight a specific area in the plot.
594+
By itself will only fill rectangular areas in the plot area. However, it can be used in conjunction with other modules to create
595+
more complex plots. Refer to the examples for more details.
596+
597+
=====================
598+
Polar Plot
599+
=====================
600+
601+
Allows to plot polar graphs. You just need to give the values of the graph in a python list.
602+
See the examples folder for more information.

examples/scatter_pointers.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import board
99
from ulab import numpy as np
1010
from circuitpython_uplot.plot import Plot
11-
from circuitpython_uplot.scatter import Scatter
11+
from circuitpython_uplot.scatter import Scatter, Pointer
1212

1313

1414
# Setting up the display
@@ -34,6 +34,6 @@
3434
a = np.linspace(1, 100)
3535
b = [choice(a) for _ in a]
3636
Scatter(plot, a, b)
37-
Scatter(plot2, a, b, pointer="triangle", pointer_color=0x00FF00)
38-
Scatter(plot3, a, b, pointer="square", pointer_color=0xFFFFFF)
39-
Scatter(plot4, a, b, pointer="diamond", pointer_color=0xFF32FF)
37+
Scatter(plot2, a, b, pointer=Pointer.TRIANGLE, pointer_color=0x00FF00)
38+
Scatter(plot3, a, b, pointer=Pointer.SQUARE, pointer_color=0xFFFFFF)
39+
Scatter(plot4, a, b, pointer=Pointer.DIAMOND, pointer_color=0xFF32FF)

examples/scatter_using_different_datasets.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import board
77
from ulab import numpy as np
88
from circuitpython_uplot.plot import Plot
9-
from circuitpython_uplot.scatter import Scatter
9+
from circuitpython_uplot.scatter import Scatter, Pointer
1010

1111

1212
# Setting up the display
@@ -52,6 +52,6 @@
5252
b,
5353
rangex=[0, 210],
5454
rangey=[0, 210],
55-
pointer="triangle",
55+
pointer=Pointer.TRIANGLE,
5656
pointer_color=0x00FFFF,
5757
)

0 commit comments

Comments
 (0)