Plot Functions

You can plot functions with the Plot command. The functions to be plotted can depend on one variable. The general syntax for the plotting command is
Plot(f(x) {, x} {, property, ...})
You can enter for example the following command to plot a sine function:
Plot(Sin(x))
       Plot done
A Figure will open in which the function will be plotted. You can optionally specify the variable x explicitly. If not specified, SpeQ will detect the function variable automatically. Any name can be used for the variable. It's not necessary to use x as the variable name.

Properties

You can optionally add properties in the Plot function. An example is:
Plot(Sin(x), Color=Red, xMin=-3, xMax=3, GridStyle=Off, Title=My Figure)
       Plot done
All available properties are described on the page Edit Properties. The properties are also editable in the Property Window.

Multiple functions in one Figure

There are two ways to plot multiple functions in one figure. You can either enter multiple functions in one Plot command, or you can plot a function, keep the figure open, and plot another function. If the figure window is still open when you plot the second function, the first function will remain.
Plot(Sin(x), 2*Cos(x))
       Plot done
Plot(Sin(x))
       Plot done
Plot(2*Cos(x))
       Plot done

Multiple Figures

You can open multiple Figures at one time, up to 9 Figures. To plot a function in a second Figure instead of the first figure, you have to specify the number of the Figure.
'plot a function. this function will be plotted in Figure 1
Plot(Sin(x))
       Plot done

'plot a second function in Figure 2
Plot(Figure=2, 2*Cos(x))
       Plot done

'plot a third function in Figure 5
Figure = 5
       Figure = 5
Plot(x^2 / 10)
       Plot done

Figure

Functions will be plotted in a figure. A figure looks like this:

Traced graph

Complex values and units

Note that SpeQ can not plot functions that result in complex values or values with units. Therefore, for example the function Sqrt(x) is not plotted for values x < 0.

Back to top

Overview

SpeQ has several functions available for plotting graphs.
Function Description
Plot(f(x))
Plot(f(x), {x,} {properties})
Plot the graph of a function f(x) that depends on the variable x in a figure. Defining the variable and extra properties is optional.

PlotLogX(f(x)) PlotLogX is identical to the function Plot, except that the scale of the horizontal axis
(x-axis) is logarithmic. Just like with the function Plot, you can add aditional properties.

PlotLogY(f(x)) PlotLogY is identical to the function Plot, except that the scale of the vertical axis
(y-axis) is logarithmic.

PlotLogLog(f(x)) PlotLogLog plots the graph with both horizontal and vertical axis logarithmic.

RGB(R, G, B) Returns a color value. R, G and B are the components for the light intensity of red, green and blue. R, G and B can be any number between 0 and 255.
For example RGB(0,0,0) gives black and
RGB(255,255,255) gives white.

Close(figure)
Close(figA, figB, figC, ...)
Close one or more figures. For example enter Close(2) or Close(Figure=2) to close Figure 2. You can close the current active figure by entering Close(Figure).

CloseAll Close all figures.

Back to top

Examples

'Examples of plotting graphs

'Plot a few functions
Plot(x^2 - 3)
       Plot done
Plot(Sin(x))
       Plot done

'Enter multiple functions in one plot command
Plot(Sin(t), Cos(t))
       Plot done

'Specify properties
Plot(Figure=2, Sin(x)+Cos(2*x), Color = Pink)
       Plot done
Plot(Figure=2, 0.5*x^3-2*x^2+x, Color = Purple)
       Plot done

'Specify properties beforehand
Figure = 4;
yMin = -3;
yMax = 3;
xMax=2;
GridStyle = Off;
Plot(Exp(0.5*x));
Plot(Exp(0.5*x) * Sin(2*x));
Plot(-Exp(0.5*x));

Figure = 5
       Figure = 5
Plot(Exp(0.5*x) * Sin(2*x), LegendStyle = Off)
       Plot done

'Set tracepoint for a function
xTrace = 1.5
       xTrace = 1.570796327
'Read the traced functionvalue yTrace
yTrace
       yTrace = 0
'An intersection with the x-axis is found, xTrace is
'snapped to that intersection. analyze the found xTrace
xTrace / Pi
       Ans = 0.5

'Close figure 2 and 5
Close(2)
       Done
Close(Figure=5)
       Done

'If you want to plot a constant, you have to give the variable explicitly
'because SpeQ is unable to detect a variable in the function.
Plot(2.25)
       Error: Unable to detect a variable in function "2.25"...
'To solve the problem, define an arbitrary variable
Plot(2.25, MyFavoriteVar)
       Plot done
Back to top

See Also

Edit Properties, Graphs, Figure, Property window