Skip to content

Commit 2e951d1

Browse files
committed
FEAT: Adding new graphics functions from 3.3
1 parent 3f7ddf9 commit 2e951d1

File tree

2 files changed

+63
-0
lines changed

2 files changed

+63
-0
lines changed

arrayfire/graphics.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,46 @@ def image(self, img, title=None):
140140
_cell = _Cell(self._r, self._c, title, self._cmap)
141141
safe_call(backend.get().af_draw_image(self._wnd, img.arr, ct.pointer(_cell)))
142142

143+
def scatter(self, X, Y, marker=MARKER.POINT, title=None):
144+
"""
145+
Renders input arrays as 2D scatter plot.
146+
147+
Paramters
148+
---------
149+
150+
X: af.Array.
151+
A 1 dimensional array containing X co-ordinates.
152+
153+
Y: af.Array.
154+
A 1 dimensional array containing Y co-ordinates.
155+
156+
marker: af.MARKER
157+
Specifies how the points look
158+
159+
title: str.
160+
Title used for the plot.
161+
"""
162+
_cell = _Cell(self._r, self._c, title, self._cmap)
163+
safe_call(backend.get().af_draw_scatter(self._wnd, X.arr, Y.arr,
164+
marker.value, ct.pointer(_cell)))
165+
166+
def scatter3(self, P, marker=MARKER.POINT, title=None):
167+
"""
168+
Renders the input array as a 3D Scatter plot.
169+
170+
Paramters
171+
---------
172+
173+
P: af.Array.
174+
A 2 dimensional array containing (X,Y,Z) co-ordinates.
175+
176+
title: str.
177+
Title used for the plot.
178+
"""
179+
_cell = _Cell(self._r, self._c, title, self._cmap)
180+
safe_call(backend.get().af_draw_scatter3(self._wnd, P.arr,
181+
marker.value, ct.pointer(_cell)))
182+
143183
def plot(self, X, Y, title=None):
144184
"""
145185
Display a 2D Plot.
@@ -255,6 +295,16 @@ def close(self):
255295
safe_call(backend.get().af_is_window_closed(ct.pointer(tmp), self._wnd))
256296
return tmp
257297

298+
def set_visibility(is_visible):
299+
"""
300+
A flag that shows or hides the window as requested.
301+
302+
Parameters
303+
----------
304+
is_visible: Flag specifying the visibility of the flag.
305+
"""
306+
safe_call(backend.get().af_set_visibility(self._wnd, is_visible))
307+
258308
def __getitem__(self, keys):
259309
"""
260310
Get access to a specific grid location within the window.

arrayfire/library.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,19 @@ class BACKEND(_Enum):
315315
CUDA = _Enum_Type(2)
316316
OPENCL = _Enum_Type(4)
317317

318+
class MARKER(_Enum):
319+
"""
320+
Markers used for different points in graphics plots
321+
"""
322+
NONE = _Enum_Type(0)
323+
POINT = _Enum_Type(1)
324+
CIRCLE = _Enum_Type(2)
325+
SQUARE = _Enum_Type(3)
326+
TRIANGE = _Enum_Type(4)
327+
CROSS = _Enum_Type(5)
328+
PLUS = _Enum_Type(6)
329+
STAR = _Enum_Type(7)
330+
318331
def _setup():
319332
import platform
320333
import os

0 commit comments

Comments
 (0)