MicroPython UPLOT Library¶
plot
¶
Author(s): Jose D. Montoya
plot
¶
MicroPython Graphics Library
Author: Jose D. Montoya
-
class micropython_uplot.plot.PLOT(display, x: int =
0
, y: int =0
, width: int =100
, height: int =100
, padding: int =25
, show_box: bool =True
, background_color: int =(0, 0, 0)
, box_color: tuple =(255, 255, 255)
, tickx_height: int =8
, ticky_height: int =8
)[source]¶ Canvas Class to add different elements to the screen. The origin point set by
x
andy
properties- Parameters:¶
- display¶
display object
- x : int¶
origin x coordinate
- y : int¶
origin y coordinate
- width : int¶
plot box width in pixels
- height : int¶
plot box height in pixels
- padding : int¶
padding for the plot box in all directions
- show_box : bool¶
select if the plot box is displayed
- background_color : tuple¶
background color. Defaults to black
(0, 0, 0)
- box_color : tuple¶
allows to choose the box line color. Defaults to white ‘’(255, 255, 255)``
- tickx_height : int¶
x axes tick height in pixels. Defaults to 8.
- ticky_height : int¶
y axes tick height in pixels. Defaults to 8.
-
show_text(text: str, x: int, y: int, text_color: int | None =
None
, free_text: bool =False
, ax=None
) None [source]¶ Show desired text in the screen :param str text: text to be displayed :param int x: x coordinate :param int y: y coordinate :param int color: text color. Defaults to None :param bool free_text: Select to show free text :return: None
-
tick_params(show_ticks=
True
, tickx_height: int =8
, ticky_height: int =8
, tickcolor: int =(255, 255, 255)
, tickgrid: bool =False
, showtext: bool =False
, decimal_points: int =0
) None [source]¶ Function to set ticks parameters
- Parameters:¶
- show_ticks : bool¶
Show ticks. Defaults to
True
- tickx_height : int¶
X axes tick height in pixels. Defaults to 8
- ticky_height : int¶
Y axes tick height in pixels. Defaults to 8
- tickcolor : int¶
tick color in hex. Defaults to white.
0xFFFFFF
- tickgrid : bool¶
defines if the grid is to be shown. Defaults to
False
- showtext : bool¶
Show Axes text. Defaults to
False
- decimal_points : int¶
Number of decimal points to show. Defaults to
0
- Returns:¶
None
- static transform(oldrangemin: float | int, oldrangemax: float | int, newrangemin: float | int, newrangemax: float | int, value: float | int) float | int [source]¶
This function converts the original value into a new defined value in the new range
cartesian
¶
MicroPython cartesian graph
Author: Jose D. Montoya
-
class micropython_uplot.cartesian.Cartesian(plot: PLOT, x: list, y: list, rangex: list | None =
None
, rangey: list | None =None
, line_color: tuple =(0, 255, 0)
, line_style: str | None =None
, ticksx: list =None
, ticksy: list =None
, fill: bool =False
, pointer_index: int | None =None
)[source]¶ Class to draw cartesian plane
- Parameters:¶
- plot : Plot¶
Plot object for the scatter to be drawn
- x : list¶
x points coordinates
- y : list¶
y points coordinates
- rangex : list|None¶
x range limits. Defaults to None
- rangey : list|None¶
y range limits. Defaults to None
- line_color : int|None¶
line color. Defaults to None
- line_style : str|None¶
line style. Defaults to None
- ticksx : list¶
X axis ticks values
- ticksy : list¶
Y axis ticks values
- fill : bool¶
Show the filling. Defaults to
False
- pointer_index : int|None¶
Pointer index. Defaults to None
scatter
¶
scatter plot for micropython_uplot
Author: Jose D. Montoya
-
class micropython_uplot.scatter.Scatter(plot: PLOT, x: list, y: list, rangex: list | None =
None
, rangey: list | None =None
, radius: list | int | None =3
, pointer_color: tuple =(0, 255, 0)
, pointer: str | None =None
, pointer_index: int | None =None
)[source]¶ Main class to display different graphics
- Parameters:¶
- plot: PLOT¶
Plot object for the scatter to be drawn
- x: list¶
x points coordinates
- y: list¶
y points coordinates
- rangex : list|None¶
x range limits
- rangey : list|None¶
y range limits
- radius : int|list¶
circle radius
- pointer_color : int¶
pointer color. Default is 0xFF905D
- pointer : str|None¶
pointer shape.
- pointer_index : int|None¶
pointer index. Default is None
bar
¶
MicroPython bar graph
Author: Jose D. Montoya
-
class micropython_uplot.bar.Bar(plot: PLOT, x: list, y: list, fill: bool =
False
, bar_space: int =16
, xstart: int =50
, color_palette: list | None =None
, max_value: float | int | None =None
)[source]¶ Main class to display different graphics
- Parameters:¶
- plot : Plot¶
Plot object for the scatter to be drawn
- x : list¶
x data
- y : list¶
y data
- fill : bool¶
boxes fill attribute. Defaults to
False
- bar_space : int¶
space in pixels between the bars
- xstart : int¶
start point in the x axis for the bar to start. Defaults to
50
- color_palette : list¶
list of colors to be used for the bars. Defaults to None. Be aware that you need to include the same number if colors as your data. This functionality will only work with filled bars.
- max_value : int¶
for filled unprojected bars will setup the maxium value for the bars. This allows the user to update the bars in real-time. There is an example in the examples folder showing this functionality
logging
¶
MicroPython logging utility
Author: Jose D. Montoya
-
class micropython_uplot.logging.Logging(plot: PLOT, x: list, y: list, rangex: list | None =
None
, rangey: list | None =None
, line_color: tuple =(0, 255, 0)
, ticksx: list =(0, 10, 30, 50, 70, 90)
, ticksy: list =(0, 10, 30, 50, 70, 90)
, tick_pos: bool =False
, fill: bool =False
)[source]¶ Class to log data
- Parameters:¶
- plot : Plot¶
Plot object for the scatter to be drawn
- x : list¶
x points coordinates
- y : list¶
y points coordinates
- rangex : list|None¶
x range limits. Defaults to Nonem
- rangey : list|None¶
y range limits. Defaults to None
- line_color : int|None¶
line color. Defaults to None
- ticksx : list¶
X axis ticks values
- ticksy : list¶
Y axis ticks values
- tick_pos : bool¶
indicates ticks position. True for below the axes. Defaults to
False
- fill : bool¶
enable the filling of the plot. Defaults to
False
- static clear_plot(plot: PLOT) None [source]¶
Clears the plot area :param PLOT plot: plot object provided
map
¶
MicroPython color map graph
Author: Jose D. Montoya
- class micropython_uplot.map.Map(plot: PLOT, data_points: list, data_points_max: float, matrix_shape: list, initial_color: tuple, final_color: tuple)[source]¶
Main class to display different graphics
Due to IL9436 Display driver limitations number of map colors is limited to 10 :param PLOT plot: Plot object for the scatter to be drawn :param list data_points: data points to create the color map :param float data_points_max: data points max value :param list matrix_shape: data_points matrix shape :param tuple initial_color: initial color to create the color map :param tuple final_color: final color to create the color map
- micropython_uplot.map.color_fade(start_color: int, end_color: int, fraction: float) tuple [source]¶
Linear extrapolation of a color between two RGB colors (tuple or 24-bit integer).
fillbetween
¶
MicroPython fillbetween graph
Author: Jose D. Montoya
-
class micropython_uplot.fillbetween.Fillbetween(plot: PLOT, x: list, y1: list, y2: list, rangex: list | None =
None
, rangey: list | None =None
, fill_color: int =(0, 255, 0)
, pointer_index: int | None =None
)[source]¶ Class to draw a fillbetween graph
- Parameters:¶
- plot : Plot¶
Plot object for the scatter to be drawn
- x : list¶
x points coordinates
- y1 : list¶
y1 points coordinates
- y2 : list¶
y2 points coordinates
- rangex : list|None¶
x range limits
- rangey : list|None¶
y range limits
- fill_color : int¶
filling color. Defaults to (0, 255, 0)
- pointer_index : int|None¶
Pointer index. Defaults to None