Image Display


The image command can be used to display a 2D array. Each array element is displayed as a tile filled with a color corresponding to its value.

Xmin=0; Xmax=400; Ymin=0; Ymax=360; -- Label axis in degrees
Xdiv=90; Ydiv=90
Zmin=-2; Zmax=2

-- Define an array of Z values
Zarray[ix,iy] = sin(ix*10) + sin(iy*10) dim[40,36]

image Zarray

plot sin(X)*50+200 -- overlay a line plot

The entire array is displayed and fills the plot area regardless of the values of Xmin, Xmax, Ymin, or Ymax. These values can be set as desired to show whatever axis is appropriate for the data.

The array is displayed "sideways" meaning that array element A[1,1] is displayed in the lower left corner. This convention results in a simple correspondence between an element A[ix,iy] and the plot x,y coordinate system.

Arrays that are larger than the number of display pixels are allowed. Arrays with dimensions larger than 3000 will be reduced to 3000 by undersampling.

The image command displays an array but any function can be converted to an array. To sample a function over some arbitrary range of x and y values you can scale array index values to generate the desired x and y values.

Z scale

Mapping of an element's numeric value to a color level is controlled by special variables Zmin and Zmax. They define the range of values that are of interest. Values at or above Zmax are displayed as the highest color level. Values at or below Zmin are displayed as the lowest color level. Values near Zmin are blue and range up through green and yellow to red at Zmax. Missing data is always displayed as white. If grayscale is selected, min is white and max is black.

The color mapping can be changed by the optional function ColorTable(RGBarray). Arbitrary RGB values can be loaded into the table. ColorTable(0) will set the table to grayscale. ColorTable(1) will reset the table to the default colors. This function is not enabled by default but it can be enabled via the Functions window.

A color bar across the top of the plot shows the color scale. This bar can be suppressed by setting the special variable Zshowbar=off

Auto Ranging

If Zmin and/or Zmax are not specified, MathPad will use Zlo and/or Zhi from the previous evaluation. This is similar to the way plots are auto-ranged except that the user must re-evaluate the document to get the new Z scale. This was done because of the time involved in evaluating an array twice. It seemed best to give the user another chance at setting the scale before evaluating again.

Plot Trace Overlays

The plot command can be used in conjunction with the image command. The plot will be drawn on top of the image.

Graphics Overlays

A picture or other graphic can be added to the plot. The command

imagefile "name"

will read in the named graphics file and add it to the plot. The imagefile layer is between image data and plot traces. The graphic will obscure the image unless there are transparent areas.

The graphics file is assumed to be in the same folder as the source document. Path names can also be used. Any of several common graphics file formats such .jpg, .tif .png can be used.

By default the graphic is sized to fill the entire axis area. An optional rectangle in data coordinates can be specified to place the graphic at a particular place.

imagefile "name", {x0,y0,width,height}

Only one imagefile layer can be used per strip.

Click Info

When the mouse is clicked on the image the corresponding X,Y and Z values are printed in the info line at the bottom of the plot. Since only the display information is saved, the Z value shown is approximate and will not show values outside of Zmin to Zmax. If the image has a plot trace overlay the mouse click will pick a nearby plot X,Y point over an image point.