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.
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.
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
The default color map can be changed by the XFun Ctab. Direct control of colors is possible with the XFun imageRGB. See XFuns for information on how to install these extra features.
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.
The Preferences... Image... dialog can be used to alter the appearance of the image to best fit your particular tastes.
halftone patterns -- Data is displayed as differing black and white patterns. This option left over from ancient times when not everyone had a color screen.
gray levels -- Data is displayed as levels of gray. Some kinds of data work better as grayscale. It is often a better choice for printing.
color -- Data is displayed as differing colors.
dithering -- If this box is checked, intermediate gray levels or colors are created by mixing screen pixels of more than one color. This results in a smoother scale. Most screens these days are set to display thousands of colors so this option isn't needed.
Since your printer may not have the same capabilities as your screen, the image dialog is presented when you print a plot containing an image. Unless you have a color printer you will probably want to print the image as gray levels.
The plot command can be used in conjunction with the image command. The plot will be drawn on top of the image.
A PICT pasted into the plot goes on top of the image. If the PICT is a line drawing, the image will be visible through the PICT but a bitmap will obscure the entire image.
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 overlay the mouse click will pick a nearby plot X,Y point over an image point.