Maple/Graphic functions

Chapter 6: Graphic functionsEdit

Simple plotsEdit

To plot a funtion you use the plot(function) command. You need to tell Maple what variable it needs to plot against the value function. This is done by plot(funtion, variable=a..b). This will plot the value of the function as the variable changes from a to b. Example:

>plot(x^2, x=0..1);     #Image on the left
>plot(1/3*x^3, x=-1..1);     #Image on the right
Plotof-xsquared.pngPlotof-onethirdxcubed.png

You can also get Maple to plot a function that you have entered previously.

>2/3*x^2+x;
>plot(%, x=-2..1);
Plotof-twothirdsxsquaredplusone.png

Maple will also accept variables in the range option if it can equate the function to those extremes. This is particulary useful if you are plotting trigonometric functions as you can then make use of multiples of pi.

>plot(cos(x), x=0..2*Pi);     #Image on the left
>a:=Pi:     #Affecting the variable a to equal pi
>plot(sin(x), x=-a..a);     #Image on the right
Plotof-cosinex.pngPlotof-sinex.png

There are many other options you can apply to a plot.

>plot(x^3+3*x^2+x-1, x=-3..1, colour=blue, style=point, title="This is a title");     #Image on the left
>plot(-x^3-3*x^2-x+1, x=-3..1, colour=green, thickness=2, labels=["X axis label", "Y axis label"], labeldirections=[horizontal, vertical]);     #Image on the right
Plot-options1.pngPlot-options2.png

Saving of plotsEdit

For using (storing, publishing), the figures should be prepared in an appropriate format (gif, jpg, pdf, eps) and saved to disk. Such a convertion can be achieved by setting the device with the command plotssetup. Example:

> plotsetup(ps)

This command specifies that the graphic should be prepared in the EncapsulatedPostscript format. However, after such a command, while all other setting required is well arranged the plot command may cause errors. Therefore, after such a command, the command

> plotsetup(default)

can be very useful; especially while the user tries all the options one by one trying to catch the combination of commands which writes the picture into a file.

However, there exist also a way of saving pictures by use of the menu. The user should click on the figure ("mark it"), then find the option plot at the top menu bar and open the second-order menu "export" at its bottom, where the user has to choose the file-format to export to. This work should be repeated for each picture saved or updated.

Display multiple graphs in single plotEdit

t2 := plot(g2(y), y = 1 .. 10, color = red): t4 := plot(g4(y), y = 1 .. 8, color = blue): t6 := plot(g6(y), y = 1 .. 8): display({t2, t4, t6});

Maple display three curves

Rotation and reflection of plotEdit

Maple plot rotate

>K2 := plot(g2, y = 0 .. 10,color=red): plottools:-reflect(plottools:-rotate(K2, (1/2)*Pi), [[0, 0], [0, 1;

K4:= plot(g4, y = 0 .. 10,color=blue): plottools:-reflect(plottools:-rotate(K4, (1/2)*Pi), [[0, 0], [0, 1]]);

>K6 := plot(g6, y = 0 .. 10, color = black); plottools:-reflect(plottools:-rotate(K6, (1/2)*Pi), [[0, 0], [0, 1]]);

Maple diplay two curves rotate and refect
Maple diplay three curves rotate and refect

AnimationEdit

f:=2*k^2/cosh(k*(x-4*k^2*t))^2


with(plots); animate(subs(k = .5, f), x = -30 .. 30, t = -10 .. 10, numpoints = 200, frames = 50, color = red, thickness = 3);

|

bell soliton



animate3d(cos(t*x)*sin(3*t*y), x = -Pi .. Pi, y = -Pi .. Pi, t = 1 .. 2)

3D animation
Last modified on 10 November 2013, at 13:38