@@ -66,6 +66,13 @@ class Cartesian(Widget):
66
66
:param int pointer_radius: pointer radius in pixels defaults to 1
67
67
:param int pointer_color: pointer color. Defaults to white (0xFFFFFF)
68
68
69
+ :param bool subticks: inclusion of subticks in the plot area. Default to False
70
+
71
+ :param int nudge_x: movement in pixels in the x direction to move the origin.
72
+ Defaults to 0
73
+ :param int nudge_y: movement in pixels in the y direction to move the origin.
74
+ Defaults to 0
75
+
69
76
70
77
**Quickstart: Importing and using Cartesian**
71
78
@@ -110,7 +117,10 @@ class Cartesian(Widget):
110
117
The `cartesian` widget has some options for controlling its position, visible appearance,
111
118
and scale through a collection of input variables:
112
119
113
- - **position**: ``x``, ``y`` or ``anchor_point`` and ``anchored_position``
120
+ - **position**: ``x``, ``y``, ``anchor_point``, ``anchored_position`` and
121
+ `nudge_x`, `nudge_y`. Nudge parameters are used to account for the float and int
122
+ conversions required to display different ranges and values. Conversion are required
123
+ as displays work in integers and not floats
114
124
115
125
- **size**: ``width`` and ``height``
116
126
@@ -168,6 +178,8 @@ def __init__(
168
178
pointer_radius : int = 1 ,
169
179
pointer_color : int = 0xFFFFFF ,
170
180
subticks : bool = False ,
181
+ nudge_x : int = 0 ,
182
+ nudge_y : int = 0 ,
171
183
** kwargs ,
172
184
) -> None :
173
185
@@ -286,6 +298,9 @@ def __init__(
286
298
y = 0 ,
287
299
)
288
300
301
+ self ._nudge_x = nudge_x
302
+ self ._nudge_y = nudge_y
303
+
289
304
self ._draw_axes ()
290
305
self ._draw_ticks ()
291
306
@@ -476,8 +491,10 @@ def update_line(self, x: int, y: int) -> None:
476
491
:return: None
477
492
rtype: None
478
493
"""
479
- local_x = int ((x - self ._xrange [0 ]) * self ._factorx )
480
- local_y = int ((self ._yrange [0 ] - y ) * self ._factory ) + self .height
494
+ local_x = int ((x - self ._xrange [0 ]) * self ._factorx ) + self ._nudge_x
495
+ local_y = (
496
+ int ((self ._yrange [0 ] - y ) * self ._factory ) + self .height + self ._nudge_y
497
+ )
481
498
if x < self ._xrange [1 ] and y < self ._yrange [1 ]:
482
499
if local_x > 0 or local_y < 100 :
483
500
if self ._update_line :
0 commit comments