Xmin=-10; Xmax=10
Xdiv=2
plot 5*X
f(t) = t^3/10 - 5*t
plot f(X)
plot f(2*X)/10
label f(5):-12.500
Title = "Example Plot"
Ylabel = "f(X)"
Various aspects of the plot are be controlled by several plot control variables. None of these special variables are required but usually at least Xmin and Xmax are specified.
An info line at the bottom of the plot window shows the lowest and highest Y values (Ylo and Yhi) calculated during the plot. Clicking the mouse on the plot will show the trace number and the X,Y value of the plotted point nearest to the click.
The variables Ymin and Ymax can be used to set the Y axis limits. If Ymin and/or Ymax are not specified MathPad will auto-range based on Ylo and Yhi.
The special variables Ylo and Yhi can be used to provide initial axis limits for cases where the plot takes some time to draw. If these variables are used with autoranging, they set the initial axis. The axis will be redrawn to the actual range when the trace is complete. The computed values of Ylo and Yhi are available after each plot statement.
Multiple traces can be plotted simply by adding plot statements. Each new trace is drawn in a different color. Traces cycle through four colors: black, red, green and blue. The auto cycle can be overridden by setting the variable Tracecolor. For example Tracecolor=2 will plot all traces in red. Also see Marker symbols.
Axis ticks can be controlled by the variables Xdiv and Ydiv. If these variables are used they override the automatic axis. They specify the distance between labeled ticks in data units. The axis label format still assumes that "nice" divs (at most 2 digits of precision) will be used. This means that a div like .2 or .25 will work but a div of .234 will have rounded tick labels. If there are too many or too few divisions the axis will revert to automatic divisions.
Arbitrary text labels may be pasted into the plot window. Selecting "Paste Label" from the Edit menu will paste text from the clipboard into the upper left corner of the plot. Command-V will paste the label at the current mouse position if it is in the plot window. Labels can be moved by dragging with the mouse. Labels can be deleted by dragging them off the plot.
A label command can be used to put a line from the text window onto the plot as a movable label. The text following label is evaluated normally. This allows labels that will automatically update when the text is reevaluated.
The slabel command is similar except that it expects a string expression. The resulting string contents are placed on the plot as a movable label.
Special variables Xlabel, Ylabel and Title allow adding labels at preassigned locations. The plot size is adjusted to make room for these labels if they are present. These labels are not movable.
The current date can be automatically added to the upper right corner of the plot by using Datelabel=on or by checking the box in the Preferences... dialog. This will document the date when the plot was saved or printed. If you want a fixed date associated with the data in the plot, don't use this option. Use slabel and type in an appropriate date.
Grid lines can be turned on and off with Xshowgrid, Yshowgrid or with the Preferences... dialog. Axisbox allows the option of a box drawn around all four sides of the plot.
A picture can be pasted from the clipboard into the plot to provide a background. The picture will be sized to fit inside the axis. See the example file "Navigation" where a picture of a world map is used as a background for a latitude longitude plot.
s(t) = 100*sin(t)/t
Xmin=-200; Xmax=200
Ymin=0
plot s(X)
newaxis
Xmin:=-2500:; Xmax:=2500:
Ymin:=?:-- enable autorange
plot s(X)
The newaxis command can be used to put more than one set of axes on a page. The plot control variables can be changed following a newaxis. They must be changed with an := assignment. All changes to plot control variables must appear before the first plot statement for the new axis.
Any plot control variables that are not assigned will keep their previous values. A variable can be set back to undefined by assigning "?"
The variable Ystrips can be used to preset the number of different axes that will be put on the page. The use of Ystrips is optional. It can be used to prevent extra redrawing of the plot window. Ystrips can either be set to the number of equal height strips (Ex. Ystrips=2) or it can be set to an array where the elements give a relative height for each strip. Ystrips = {1.7,1,1} specifies 3 strips, the 1st strip is given 70% more height. Log axes can be set with the Preferences... dialog or with Xlogaxis or Ylogaxis. With this option set, the values are plotted with logarithmic spacing and the axis tick labels are changed appropriately. See log axes
Plotting arrays
The plot command can also plot points from 1D or 2D arrays.
Arrays can be given in 5 forms:
![]() |
|
For a 1D array {y1,y2,y3...} the element values are used for y. The points are plotted evenly spaced along the current X axis.
For 2D arrays, both x and y are taken from the array. When plotting x,y points, if Xmin and/or Xmax are not specified they will be auto-ranged. When plotting a mix of arrays and functions, the array should be plotted first to take advantage of X auto-ranging. The Xlo and Xhi variables can be preset by the user to provide a hint for autoranging or to access the min and max plotted X values.
The plot command plots a marker at each point. The plotline command can be used to connect the points for any array plot. For {x,y} plots the points are connected in the order that they appear in the array. An undefined point causes the pen to be lifted. The pen is put down when the next defined point is found. If a single defined point is surrounded by undefineds it will not be plotted.
Arrays can be read in from data files.
When arrays are plotted using plot each point is plotted as a marker symbol. Each trace uses a different symbol and color.
Markers and colors cycle so that many different traces can be plotted and each will be given a unique colored symbol.
Control variables can be used to override the default cycle. The variable Marker can be used to set which marker is used. The variable Markersize can be used to increase or decrease the size of marker symbols. Markersize=2 gives a marker that is roughly twice the default size. Tracecolor can be used to control the color of the markers and traces. The four trace colors are: 1-black, 2-red, 3-green and 4-blue.
These control variables can be changed between each trace using :=. They can also be set to an array that specifies a separate value for each trace. Tracecolor={1,4,4,3,2}
would specify a trace sequence of black, blue, blue, green, red. If an array is used there must be enough elements to specify all traces plotted.
If a valid marker is specified for a plotline trace of an array, both markers and connecting lines will be plotted (equivalent to plotting with both plot and plotline). If a marker of zero is specified for a plot trace, connecting lines will be drawn with no markers (equivalent to using plotline).
For {fx(X),fy(X)} Xmin and Xmax specify the range of fx() values that will be plotted. The variable X is stepped from 0 to 1.0 regardless of Xmin and Xmax. The values of X can be scaled to produce an independent variable that is used to calculate both x and y.
![]() |
|
deg[i] = (i-1)*10 dim[37]-- run deg 0 to 360 in 10° steps
polar(r,theta) = {r*cos(theta),r*sin(theta)}
cardoid(theta) = 1-cos(theta)
deg[i] = (i-1) dim[361]-- run deg 0 to 360
Xmin=-2; Xmax=2; Ymin=-2; Ymax=2
plotline polar(cardoid(deg),deg)
An array of 3 or more functions will be plotted as multiple traces. X is stepped from Xmin to Xmax for each function.
![]() |
|
The XFun viewsurf can be used to show a 3D projection of a surface. See 3D plotting.
MathPad can save a sequence of plots as frames in a QuickTime movie. Movies require the XFun QTmovie. The function movie(fname,nframes) returns the frame number. A slider control window allows preview. When the record button is pressed, the document is evaluated "nframes" times. Each resulting plot is added as a frame to the movie.
For printing, the plot is re-sized to the page regardless of the current plot window size. The plot window zoom box sets the window to the current printer page aspect. This allows a crude print preview so you can position labels appropriately for printout.
In some cases it is important to preserve the shape of a plot. The plot can be printed at the size and shape of the plot window by checking "Print as sized" in the Preferences... dialog. There is also an option to control whether the info line is included in the print.
Printing is done at higher resolution than the screen so it may be useful to increase Xsteps for a smoother plot. It may also be useful to change the font or size of the labels with the Format menu.
The Save Plot... menu item allows you to save the plot window as a PICT file. You can set the size and scaling of the PICT.
PICT files at the default 72dpi resolution tend to look jaggy when printed or enlarged. Scaling up or changing the resolution allows the export of higher resolution plots. The treatment of PICT resolutions varies widely with application so you may need to experiment to find what works best with the application you are exporting to. Note that the OS-X Preview application is surprisingly poor at viewing PICT files. Other applications may give better results.
Save Plot... also allows you to use QuickTime to save directly in different graphics formats such as JPEG and TIFF. You should see an Export... button in the dialog if Quicktime 3.0 or better is installed on your system. The number of output formats available will depend on which QuickTime converters are installed. Most QuickTime formats are bitmap representations which will be less scaleable than the orignal PICT and generate much larger files.
The plot can be copied to the clipboard as a PICT. The "Copy Plot" menu items are enabled when the plot window is in front. The clipboard image will be the same size as the current plot window size. The "Copy Plot at 4X" command scales the image up to provide a higher resolution image for applications that can import and re-size PICTs. For applications that support high resolution PICTs, use the Preferences... dialog to set Copy at 288dpi. This will change the menu item so that the plot will be copied at high resolution without having to re-size it.
You can also use Print Plot... to create PostScript or PDF files. This is a system feature available for any printout but it may be particularly useful for exporting plots.
In OS-9, if you choose to a PostScript printer, the dialog will have a "Destination" option that can be set to "File" and also a general "Save As File" pop-up to select more details.
In OS-X the print dialog has a "Save As PDF" button.
Saving a PostScript file is a litte trickier. In OS-10.3 you first select a PostScript printer and then under the pop-up that typically says "Copies & Pages" there is a choice "Output Options" where you can choose to save a PostScript file. If you don't have a PostScript printer in your printer list you can add one as an IP printer address "localhost"
Movies
frame := movie("ex.mov",20):
label frame:20.000
Xmin=-1; Xmax=1
Ymax=.019; Ymin=-.005
u = 90*frame*X
plot sin(u)/u
Plot Output
Graphics Export
X | independent variable | |||||||||||||||||||
Xmin=n | minimum value for X axis | |||||||||||||||||||
Xmax=n | maximum value for X axis | |||||||||||||||||||
Xsteps=n | resolution for stepping X values | |||||||||||||||||||
Xdiv=n | distance between axis ticks | |||||||||||||||||||
Xlabel="label" | add X axis label | |||||||||||||||||||
Xlogaxis=on | use log X axis | |||||||||||||||||||
Xshowgrid=on | show vertical grid lines | |||||||||||||||||||
Xticklabels=off | suppress X axis numeric tick labels | |||||||||||||||||||
Xlo=n | initial X axis min with autorange | |||||||||||||||||||
Xhi=n | initial X axis max with autorange | |||||||||||||||||||
Ymin=n | minimum value for Y axis | |||||||||||||||||||
Ymax=n | maximum value for Y axis | |||||||||||||||||||
Ydiv=n | distance between axis ticks | |||||||||||||||||||
Ylabel="label" | add Y axis label | |||||||||||||||||||
Ylogaxis=on | use log Y axis | |||||||||||||||||||
Yshowgrid=on | show horizontal grid lines | |||||||||||||||||||
Yticklabels=off | suppress Y axis numeric tick labels | |||||||||||||||||||
Ylo=n | initial Y axis min with autorange | |||||||||||||||||||
Yhi=n | initial Y axis max with autorange | |||||||||||||||||||
Zmin=n | image data minimum | |||||||||||||||||||
Zmax=n | image data maximum | |||||||||||||||||||
Zlabel="label" | add Z axis label | |||||||||||||||||||
Zlogaxis=on | log image data | |||||||||||||||||||
Zshowbar=off | suppress Z color bar | |||||||||||||||||||
Ystrips=n | preset the number of different axes | |||||||||||||||||||
Ystrips={1,2,...} | preset relative height of each strip | |||||||||||||||||||
Title="label" | add label at top of page | |||||||||||||||||||
Datelabel=on | put current date at upper right | |||||||||||||||||||
Axisbox=on | draw a box around the plot | |||||||||||||||||||
Tracecolor= | 1-black, 2-red, 3-green, 4-blue | |||||||||||||||||||
Marker= | ![]() | |||||||||||||||||||
Markersize=2.0 | use double size markers |