Access Keys:
Skip to content (Access Key - 0)

How can I plot data in Maple?

The basic plot syntax is:

	> plot(f(x), x=a..b)	
  e.g.  > plot(sin(x), x=-Pi..Pi);

for a parametric plot:

	> plot([fx(t),fy(t), t=a..b])	

  e.g.	> plot([sin(t),cos(t), t=0..2*Pi]);

for a 3D plot:

	> plot3d(f(x,y), x=a..b, y=c..d)

  e.g.  > plot3d(sin(x*y), x = -Pi..Pi, y = -Pi..Pi);

For information on changing the appearance of a plot, adding a title, etc., type:

	> ?plot[options]

The "plots" package contains functions for many other types of plots (type ?plots for a complete list).

To plot of a set of 2D points, you can give the points as a bracketed list and use the "style=point" option. For example:

        > plot([[1,2], [-1,2], [1,3]], style=point);

Another way to do this is to use "pointplot" from the "plots" package; "plots" also includes an analagous "pointplot3d" function for plotting sets of 3D points. For example:

        > with(plots);
	> pointplot([[1,2], [-1,2], [1,3]]);

        > pointplot3d([[0,1,1], [1,2,2], [1,3,5]]);

        > pointplot3d([[0,1,1], [1,2,2], [1,3,5]],axes=boxed,color=red);

Here is an example of how to take two lists of data (containing, for example "x" values and "y" values), combine them with the 'zip' routine, and plot them with "x" values on the horizontal axis, "y" on the vertical:

        > xlist := [0,1,2,3]:
        > ylist := [-1,1,-2,2]:
        > xylist := zip( (x,y) -> [x,y], xlist, ylist );

                xylist := [[0,-1],[1,1],[2,-2],[3,2]]

        > plot(xylist, style=point);

To reverse things so that the "x" values are displayed vertically:

         > xylist := zip( (x,y) -> [y,x], xlist, ylist );

                 xylist := [[-1,0],[1,1],[-2,2],[2,3]]

         > plot(xylist, style=point);

For more information, see online help on the topics: plot, plot3d,pointplot, pointplot3d, plots

IS&T Contributions

Documentation and information provided by IS&T staff members

Last Modified:

February 25, 2009

Get Help

Request help
from the Help Desk
Report a security incident
to the Security Team
olc-maple olc-maple Delete
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.
This product/service is:
Easy to use
Difficult to use

This article is:
Adaptavist Theme Builder (4.2.3) Powered by Atlassian Confluence 3.5.13, the Enterprise Wiki