Back to Maple Tutorial Table of Contents
Until now, we have only used the computational portion of Maple. Now we are going to take a look at the plotting aspect. Since plotting in Maple can get complicated, several topics of the Maple Tutorial will be devoted entirely to plotting.
The first command we will learn is the command you will probably use the most. plot() is a command that can do almost any type of plot whether it's 2D, 3D, parametric, polar, cylindrical, or spherical.
The most simple form of plot() is:
where f(x) is the function you want plotted,
x is the independent variable,
and a..b is the range to plot f(x)
Example: To plot f(x) = x on a closed interval from -10 to 10, you would use
> plot(f(x),x=-10..10); #You can create a function and plot a function too.
You can plot functions with another independent variable besides x.
Surprise! You can also plot trig functions.
In this example, theta is a variable like x and y. Some people like to use theta instead of x or y when dealing with trig functions.
Make sure you tell Maple what is the independent variable. Watch what happens if you make a mistake.
Plotting error, empty plot
You will see this error message a lot. Since it's not really helpful (most anything could cause this error), you will have to do a bit of detective work to fix it. Review each chunk of the plot statement and make sure that each piece evaluates to the right data type. For example.
Error, (in plot/options2d) unknown or bad argument, x = 3
In the example above, the sqrt(9) statement was correct in syntax, but not correct for function. It didn't make sense to put a number there instead of a range.
After you've reviewed each chunk individually, evaluate the plot statement as a whole. In the first example, the y=-10..10 did not go with the x. Maple has no idea what to do with x but it knows what to do with y. The ironic thing is that it has no place to "show" its knowledge about y. Since Maple doesn't know what to do with x, it complains.
Here's another common error. Can you spot the error? (I have put the statements on the same line to save space)
Once again, a mystery. The problem is that the f in the plot statement literally evaluates to x->x2. Maple has no idea how to plot that. Remember when we learned about functions? One of the things we learned stated that to receive a number from a function, you must use the form f(x), not just f. To remedy the error, either use plot(f(x), x = a..b) OR plot(f, a..b).
Maple allows you to modify your plot via the plot() statement. These modifiers are arguments to the plot() statement. They take the form
where option is a predefined option to modify
and value is its new value.
As with any arguments in any statement, the plot options are set off from each other with a comma.
Here are the most common:
This lets you modify the y range. In a 2D plot, the y-axis range doesn't need an option name. The view= is in brackets because not all plot commands require it.
scaling allows you to determine whether the x-axis and the y-axis have the same scale. Constrained means they do have the same scale; unconstrained (the default) means they do not.
color (also spelled colour) allows you to change the color of your plot. Some colors you can use are red, green, blue, black, and magenta.
thickness is a number from 1 to 3 that specifies the line thickness of the plot.
linestyle allows you to change the style of line for the plot. The options are solid, dot, dash, and dash-dot
axes allows you to change the style of axes on the plot.