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:
> plot(f(x),x=a..b);
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(x,x=-10..10);
![[Maple Plot]](../images/plot-011.gif)
> f:=x->x;
![]()
> plot(f(x),x=-10..10); #You can create a function and plot a function too.
![[Maple Plot]](../images/plot-013.gif)
You can plot functions with another independent variable besides x.
> plot(a^3,a=-10..10);
![[Maple Plot]](../images/plot-014.gif)
Surprise! You can also plot trig functions.
> plot(sin(2*theta)-cos(theta/2),theta=0..2*Pi);
![[Maple Plot]](../images/plot-015.gif)
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.
> plot(x,y=-10..10);
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.
> plot(x,x=sqrt(9));
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)
> restart;f:=x->x^2;plot(f,x=-10..10,10..10);
![]()
![[Maple Plot]](../images/plot-017.gif)
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
option=value
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:
[view=]a..b
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.
> plot(x,x=-10..10,-10..10);
![[Maple Plot]](../images/plot-018.gif)
scaling=[constrained|unconstrained]
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.
> plot(x,x=-10..10,scaling=constrained);
![[Maple Plot]](../images/plot-019.gif)
color=value
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.
> plot(x,x=-10..10,color=magenta);
![[Maple Plot]](../images/plot-0110.gif)
thickness=[1|2|3]
thickness is a number from 1 to 3 that specifies the line thickness of the plot.
> plot(x,x=-10..10,thickness=3);
![[Maple Plot]](../images/plot-0111.gif)
linestyle=[1|2|3|4]
linestyle allows you to change the style of line for the plot. The options are solid, dot, dash, and dash-dot
> plot(x,x=-10..10,linestyle=3);
![[Maple Plot]](../images/plot-0112.gif)
axes=[none|normal|box|frame]
axes allows you to change the style of axes on the plot.
> plot(x,x=-10..10,axes=none);
![[Maple Plot]](../images/plot-0113.gif)