arrayfire.graphics module¶
Graphics functions (plot, image, etc).
-
class
arrayfire.graphics.
Window
(width=1280, height=720, title=’ArrayFire’)[source]¶ Bases:
object
Class to create the Window object.
Parameters: width: optional: int. default: 1280.
- Specifies the width of the window in pixels.
height: optional: int. default: 720.
- Specifies the height of the window in pixels.
title: optional: str. default: “ArrayFire”.
- Specifies the title used for the window.
Methods
close
()Close the window. grid
(rows, cols)Create a grid for sub plotting within the window. hist
(X, min_val, max_val[, title])Display a histogram Plot. image
(img[, title])Display an arrayfire array as an image. plot
(X, Y[, Z, line, title])Display a 2D or 3D Plot. plot2
(line[, title])Display a 2D Plot. plot3
([X, Y, Z, line, title])Display a 3D Plot. scatter
(X, Y[, Z, points, marker, title])Renders input arrays as 2D or 3D scatter plot. scatter2
(points[, marker, title])Renders the input array as a 2D Scatter plot. scatter3
(points[, marker, title])Renders the input array as a 3D Scatter plot. set_axes_limits
(xmin, xmax, ymin, ymax[, …])Set axis limits. set_colormap
(cmap)Set the colormap for the window. set_pos
(x, y)Set the position of window on the screen. set_size
(w, h)Set the windo height and width. set_title
(title)Set the title of the window set_visibility
(is_visible)A flag that shows or hides the window as requested. show
()Force the window to display the contents. surface
(x_vals, y_vals, z_vals[, title])Renders the input array as a 3D surface plot. vector_field
(xpoints, xdirs, ypoints, ydirs)Display a 2D or 3D Vector_Field. -
grid
(rows, cols)[source]¶ Create a grid for sub plotting within the window.
Parameters: rows: int.
Number of rows in the grid.
cols: int.
Number of columns in the grid.
-
hist
(X, min_val, max_val, title=None)[source]¶ Display a histogram Plot.
Parameters: X: af.Array.
A 1 dimensional array containing the histogram.
min_val: scalar.
A scalar value specifying the lower bound of the histogram.
max_val: scalar.
A scalar value specifying the upper bound of the histogram.
title: str.
Title used for the histogram.
-
image
(img, title=None)[source]¶ Display an arrayfire array as an image.
Parameters: img: af.Array.
A 2 dimensional array for single channel image. A 3 dimensional array for 3 channel image.
title: str.
Title used for the image.
-
plot
(X, Y, Z=None, line=None, title=None)[source]¶ Display a 2D or 3D Plot.
Parameters: X: af.Array.
- A 1 dimensional array containing X co-ordinates.
- Not used if line is not None
Y: af.Array.
- A 1 dimensional array containing Y co-ordinates.
- Not used if line is not None
Z: optional: af.Array. default: None.
- A 1 dimensional array containing Z co-ordinates.
- Not used if line is not None
line: optional: af.Array. default: None.
- A 2 dimensional array of size [n 2]. Each column denotes X and Y co-ordinates for plotting 2D lines.
- A 3 dimensional array of size [n 3]. Each column denotes X, Y, and Z co-ordinates for plotting 3D lines.
title: str.
Title used for the plot.
-
plot2
(line, title=None)[source]¶ Display a 2D Plot.
Parameters: line: af.Array.
- A 2 dimensional array of size [n 2]. Each column denotes X, and Y co-ordinates for plotting 2D lines.
title: str.
Title used for the plot.
-
plot3
(X=None, Y=None, Z=None, line=None, title=None)[source]¶ Display a 3D Plot.
Parameters: line: af.Array.
- A 3 dimensional array of size [n 3]. Each column denotes X, Y, and Z co-ordinates for plotting 3D lines.
title: str.
Title used for the plot.
-
scatter
(X, Y, Z=None, points=None, marker=<MARKER.POINT: 1>, title=None)[source]¶ Renders input arrays as 2D or 3D scatter plot.
Parameters: X: af.Array.
A 1 dimensional array containing X co-ordinates.
Y: af.Array.
A 1 dimensional array containing Y co-ordinates.
Z: optional: af.Array. default: None.
- A 1 dimensional array containing Z co-ordinates.
- Not used if line is not None
points: optional: af.Array. default: None.
- A 2 dimensional array of size [n 2]. Each column denotes X and Y co-ordinates for 2D scatter plot.
- A 3 dimensional array of size [n 3]. Each column denotes X, Y, and Z co-ordinates for 3D scatter plot.
marker: af.MARKER
Specifies how the points look
title: str.
Title used for the plot.
-
scatter2
(points, marker=<MARKER.POINT: 1>, title=None)[source]¶ Renders the input array as a 2D Scatter plot.
Parameters: points: af.Array.
A 2 dimensional array containing (X,Y) co-ordinates.
marker: af.MARKER
Specifies how the points look
title: str.
Title used for the plot.
-
scatter3
(points, marker=<MARKER.POINT: 1>, title=None)[source]¶ Renders the input array as a 3D Scatter plot.
Parameters: points: af.Array.
A 2 dimensional array containing (X,Y,Z) co-ordinates.
marker: af.MARKER
Specifies how the points look
title: str.
Title used for the plot.
-
set_axes_limits
(xmin, xmax, ymin, ymax, zmin=None, zmax=None, exact=False)[source]¶ Set axis limits.
Parameters: xmin : af.Array.
- lower limit of the x axis.
xmax : af.Array.
- upper limit of the x axis.
ymin : af.Array.
- lower limit of the y axis.
ymax : af.Array.
- upper limit of the y axis.
zmin : optional: af.Array. default: None.
- lower limit of the z axis.
zmax : optional: af.Array. default: None.
- upper limit of the z axis.
title : str.
Title used for the plot.
-
set_colormap
(cmap)[source]¶ Set the colormap for the window.
Parameters: cmap : af.COLORMAP.
Set the colormap for the window.
-
set_pos
(x, y)[source]¶ Set the position of window on the screen.
Parameters: x : int.
Pixel offset from left.
y : int.
Pixel offset from top
-
set_size
(w, h)[source]¶ Set the windo height and width.
Parameters: w : int
Width if window.
h : int
Height of window.
-
set_title
(title)[source]¶ Set the title of the window
Parameters: title : str.
Title used for the current window.
-
set_visibility
(is_visible)[source]¶ A flag that shows or hides the window as requested.
Parameters: is_visible: Flag specifying the visibility of the flag.
-
show
()[source]¶ Force the window to display the contents.
Note: This is only needed when using the window as a grid.
-
surface
(x_vals, y_vals, z_vals, title=None)[source]¶ Renders the input array as a 3D surface plot.
Parameters: x_vals: af.Array.
A 1 dimensional array containing X co-ordinates.
y_vals: af.Array.
A 1 dimensional array containing Y co-ordinates.
z_vals: af.Array.
A 1 dimensional array containing Z co-ordinates.
title: str.
Title used for the plot.
-
vector_field
(xpoints, xdirs, ypoints, ydirs, zpoints=None, zdirs=None, points=None, dirs=None, title=None)[source]¶ Display a 2D or 3D Vector_Field.
Parameters: xpoints : af.Array.
- A 1 dimensional array containing X co-ordinates.
- Not used if points is not None
xdirs : af.Array.
- A 1 dimensional array specifying direction at current location.
- Not used if dirs is not None
ypoints : af.Array.
- A 1 dimensional array containing Y co-ordinates.
- Not used if points is not None
ydirs : af.Array.
- A 1 dimensional array specifying direction at current location.
- Not used if dirs is not None
zpoints : optional: af.Array. default: None.
- A 1 dimensional array containing Z co-ordinates.
- Not used if points is not None
zdirs : optional: af.Array. default: none.
- A 1 dimensional array specifying direction at current location.
- Not used if dirs is not None
points : optional: af.Array. default: None.
- A 2 dimensional array of size [n 2]. Each column denotes X and Y co-ordinates for plotting 2D lines.
- A 3 dimensional array of size [n 3]. Each column denotes X, Y, and Z co-ordinates for plotting 3D lines.
dirs : optional: af.Array. default: None.
- A 2 dimensional array of size [n 2]. Each column denotes X and Y directions for plotting 2D lines.
- A 3 dimensional array of size [n 3]. Each column denotes X, Y, and Z directions for plotting 3D lines.
title : str.
Title used for the plot.