Skip to content

Commit 25dc1dc

Browse files
committed
adding tick_height_argument argument for boxplot
1 parent 0ac6332 commit 25dc1dc

File tree

3 files changed

+25
-15
lines changed

3 files changed

+25
-15
lines changed

circuitpython_uplot/uplot.py

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ class Uplot(displayio.Group):
5656
:param bool show_box: select if the plot box is displayed
5757
:param int background_color: background color in HEX. Defaults to black ``0x000000``
5858
:param int box_color: allows to choose the box line color. Defaults to white ''0xFFFFFF``
59+
:param int tickx_height: x axes tick height in pixels. Defaults to 8.
60+
:param int ticky_height: y axes tick height in pixels. Defaults to 8.
5961
6062
"""
6163

@@ -69,6 +71,8 @@ def __init__(
6971
show_box: bool = True,
7072
background_color: int = 0x000000,
7173
box_color: int = 0xFFFFFF,
74+
tickx_height: int = 8,
75+
ticky_height: int = 8,
7276
) -> None:
7377
if width not in range(50, 481):
7478
print("Be sure to verify your values. Defaulting to width=100")
@@ -107,7 +111,8 @@ def __init__(
107111

108112
self._showtext = False
109113

110-
self._tickheight = 8
114+
self._tickheightx = tickx_height
115+
self._tickheighty = ticky_height
111116
self._tickcolor = 0xFFFFFF
112117
self._showticks = False
113118
self._tickgrid = False
@@ -301,7 +306,7 @@ def _draw_ticks(self, x: int, y: int) -> None:
301306
tick,
302307
self._newymin,
303308
tick,
304-
self._newymin - self._tickheight,
309+
self._newymin - self._tickheightx,
305310
2,
306311
)
307312
if self._showtext:
@@ -313,7 +318,7 @@ def _draw_ticks(self, x: int, y: int) -> None:
313318
self._plotbitmap,
314319
self._newxmin,
315320
tick,
316-
self._newxmin + self._tickheight,
321+
self._newxmin + self._tickheighty,
317322
tick,
318323
2,
319324
)
@@ -327,15 +332,15 @@ def _draw_ticks(self, x: int, y: int) -> None:
327332
tick,
328333
self._newymin,
329334
tick,
330-
self._newymin - self._tickheight // 2,
335+
self._newymin - self._tickheightx // 2,
331336
2,
332337
)
333338
for tick in subticksyrenorm:
334339
draw_line(
335340
self._plotbitmap,
336341
self._newxmin,
337342
tick,
338-
self._newxmin + self._tickheight // 2,
343+
self._newxmin + self._tickheighty // 2,
339344
tick,
340345
2,
341346
)
@@ -346,24 +351,28 @@ def _draw_ticks(self, x: int, y: int) -> None:
346351

347352
def tick_params(
348353
self,
349-
tickheight: int = 8,
354+
tickx_height: int = 8,
355+
ticky_height: int = 8,
350356
tickcolor: int = 0xFFFFFF,
351357
tickgrid: bool = False,
352358
showtext: bool = False,
353359
) -> None:
354360
"""
355361
Function to set ticks parameters
356362
357-
:param int tickheight: tick height in pixels
358-
:param int tickcolor: tick color in hex
359-
:param bool tickgrid: defines if the grid is to be shown
363+
:param int tickx_height: X axes tick height in pixels. Defaults to 8
364+
:param int ticky_height: Y axes tick height in pixels. Defaults to 8
365+
:param int tickcolor: tick color in hex. Defaults to white. ``0xFFFFFF``
366+
:param bool tickgrid: defines if the grid is to be shown. Defaults to `False`
367+
:param bool showtext: Show Axes text. Defaults to `False`
360368
361369
:return: None
362370
363371
"""
364372

365373
self._showticks = True
366-
self._tickheight = tickheight
374+
self._tickheightx = tickx_height
375+
self._tickheighty = ticky_height
367376
self._plot_palette[2] = tickcolor
368377
self._tickgrid = tickgrid
369378
self._showtext = showtext

docs/quick_start.rst

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ to use the correct keyword in the `Uplot.axs_params` function:
9292

9393
.. py:function:: Uplot.axs_params(axstype: Literal["box", "cartesian", "line"] = "box")
9494
95-
:param tickheight: Option to display the axes
95+
:param axstype: Option to display the axes
9696

9797
Options available are:
9898
* box : draws a box
@@ -111,16 +111,17 @@ the following parameters:
111111

112112
.. py:function:: Uplot.tick_params(tickheight, tickcolor, tickgrid)
113113
114-
:param int tickheight: tickheight in pixels
114+
:param int tickx_height: tickx_height in pixels
115+
:param int ticky_height: ticky_height in pixels
115116
:param int tickcolor: tickcolor in Hex format
116117
:param bool tickgrid: displays the tickgrid. Defaults to `False`
117118

118119
.. code-block:: python
119120
120-
plot.tick_params(tickheight=12, tickcolor=0xFF0008)
121+
plot.tick_params(tickx_height=12, tickcolor=0xFF0008)
121122
122123
123-
Gridlines are normally off. If you want visible gridlines then use:
124+
Gridlines are normally ``OFF``. If you want visible gridlines then use:
124125

125126
.. code-block:: python
126127

examples/uplot_tickparameters.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
)
2424

2525
# Setting up tick parameters
26-
plot.tick_params(tickheight=12, tickcolor=color.BLACK, tickgrid=True)
26+
plot.tick_params(tickx_height=12, ticky_height=6, tickcolor=color.BLACK, tickgrid=False)
2727
# Seeting some date to plot
2828
x = np.linspace(-4, 4, num=50)
2929
constant = 1.0 / np.sqrt(2 * np.pi)

0 commit comments

Comments
 (0)