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_label_format([xformat, yformat, …])

Set axis limits.

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()

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.

close()[source]

Close the window.

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_label_format(xformat='4.1%f', yformat='4.1%f', zformat='4.1%f')[source]

Set axis limits.

Parameters
xformatstr.
default: “4.1%f”.

is a printf-style format specifier for x-axis

yformatstr.
default: “4.1%f”.

is a printf-style format specifier for y-axis

zformatstr.
default: “4.1%f”.

is a printf-style format specifier for z-axis

set_axes_limits(xmin, xmax, ymin, ymax, zmin=None, zmax=None, exact=False)[source]

Set axis limits.

Parameters
xminaf.Array.
  • lower limit of the x axis.

xmaxaf.Array.
  • upper limit of the x axis.

yminaf.Array.
  • lower limit of the y axis.

ymaxaf.Array.
  • upper limit of the y axis.

zminoptional: af.Array. default: None.
  • lower limit of the z axis.

zmaxoptional: af.Array. default: None.
  • upper limit of the z axis.

titlestr.

Title used for the plot.

set_colormap(cmap)[source]

Set the colormap for the window.

Parameters
cmapaf.COLORMAP.

Set the colormap for the window.

set_pos(x, y)[source]

Set the position of window on the screen.

Parameters
xint.

Pixel offset from left.

yint.

Pixel offset from top

set_size(w, h)[source]

Set the windo height and width.

Parameters
wint

Width if window.

hint

Height of window.

set_title(title)[source]

Set the title of the window

Parameters
titlestr.

Title used for the current window.

set_visibility()[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
xpointsaf.Array.
  • A 1 dimensional array containing X co-ordinates.

  • Not used if points is not None

xdirsaf.Array.
  • A 1 dimensional array specifying direction at current location.

  • Not used if dirs is not None

ypointsaf.Array.
  • A 1 dimensional array containing Y co-ordinates.

  • Not used if points is not None

ydirsaf.Array.
  • A 1 dimensional array specifying direction at current location.

  • Not used if dirs is not None

zpointsoptional: af.Array. default: None.
  • A 1 dimensional array containing Z co-ordinates.

  • Not used if points is not None

zdirsoptional: af.Array. default: none.
  • A 1 dimensional array specifying direction at current location.

  • Not used if dirs is not None

pointsoptional: 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.

dirsoptional: 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.

titlestr.

Title used for the plot.