Skip to content

Commit d35d4a7

Browse files
committed
adding tick location
1 parent 40d317a commit d35d4a7

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

circuitpython_uplot/ulogging.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ def __init__(
4242
line_color: int = 0xFFFFFF,
4343
ticksx: Union[np.array, list] = np.array([0, 10, 30, 50, 70, 90]),
4444
ticksy: Union[np.array, list] = np.array([0, 10, 30, 50, 70, 90]),
45+
tick_pos: bool = False,
4546
fill: bool = False,
4647
) -> None:
4748
"""
@@ -54,12 +55,19 @@ def __init__(
5455
:param int|None line_color: line color. Defaults to None
5556
:param np.array|list ticksx: X axis ticks values
5657
:param np.array|list ticksy: Y axis ticks values
58+
:param bool tick_pos: indicates ticks position. True for below the axes. Defaults to ``False``
5759
:param bool fill: enable the filling of the plot. Defaults to ``False``
5860
5961
"""
6062
self.points = []
6163
self.ticksx = np.array(ticksx)
6264
self.ticksy = np.array(ticksy)
65+
if tick_pos:
66+
self._tickposx = plot._tickheightx
67+
self._tickposy = plot._tickheighty
68+
else:
69+
self._tickposx = 0
70+
self._tickposy = 0
6371

6472
plot._plot_palette[plot._index_colorused] = line_color
6573

@@ -143,9 +151,9 @@ def _draw_ticks(self, plot) -> None:
143151
draw_line(
144152
plot._plotbitmap,
145153
tick,
146-
plot._newymin,
154+
plot._newymin + self._tickposx,
147155
tick,
148-
plot._newymin - plot._tickheightx,
156+
plot._newymin - plot._tickheightx + self._tickposx,
149157
2,
150158
)
151159
if plot._showtext:
@@ -155,9 +163,9 @@ def _draw_ticks(self, plot) -> None:
155163
for i, tick in enumerate(ticksynorm):
156164
draw_line(
157165
plot._plotbitmap,
158-
plot._newxmin,
166+
plot._newxmin - self._tickposy,
159167
tick,
160-
plot._newxmin + plot._tickheighty,
168+
plot._newxmin + plot._tickheighty - self._tickposy,
161169
tick,
162170
2,
163171
)

0 commit comments

Comments
 (0)