DJ Clayworth

218 Reputation

6 Badges

19 years, 253 days

MaplePrimes Activity


These are answers submitted by DJ Clayworth

Although contacting the package author would probably be the best bet, I'm going to make a guess about what is happening here. I think the package author has assumed that the 'plots' package is loaded. What I see is a plot structure containing procedures called "display" which is exactly what you get if you try to execute the display command without saying "with(plots)". Try starting the whole worksheet afresh but saying "with(plots);" before all of the code.

If that doesn't fix it you should definitely contact the author.

David Clayworth Maplesoft GUI Developer

Which pictures are you referring to?

David Clayworth Maplesoft GUI Developer

Hi HerClau

Allow me to explain what Maple is doing. If you execute a command:

 plot(x^2,x=-1..1);

then Maple will display the plot for you. However if you assign the output of a command to a variable, such as:

 P1:=plot(x^2,x=-1..1);

then Maple assumes that you are intending to use the plot created as part of a larger plot (you can combine plots together - see the help for "plots,display" for more information). Since it assumes you don't want to see the plot right now it doesn't display it. It does however write the first line of the plot code as output, in order to tell you that something has actually happened.

If you want to see the plot as well as assign it to a variable then the simplest way is to assign it and then execute the variable - just execute

  P1;

in the above example. You can also say :

 plots[display](P1);

which will allow you to change the options on the plot without recalculating it. See the above help page for more information. Other commands that generate plots work in the same way - if you execute them without assigning to a variable then they will draw the plot; if you assign them to a variable you need to execute the variable to see the graph.

David Clayworth Maplesoft GUI Developer

"polyhedraplot" produces (surprise) polyhedra. To define general polygons in 3D space see help "polygonplot3d".

David Clayworth Maplesoft GUI Developer

I thought I'd summarise the situation.

As of Maple 11, when full math typesetting was introduced to Maple 2D plots, font=SYMBOL is no longer the recommended way of getting non-Roman characters into plots. The recommended way in the Standard GUI is to use the typesetting mechanism, as acer said. You can export individual plots using menus or plotdevice/plotsetup, all of which recognise math in plots when used from the Standard GUI. Doing this is very easy. You can export many plots (to GIF) by exporting the worksheet to HTML, or in any format by specifying the file to write to in the worksheet before each plot, just like the Sage example. Create a worksheet with the plots you need, add a plotdevice statement before each to set the filename and format, and execute the worksheet in Standard GUI.

The drivers available in command line Maple are not nearly as powerful (since command line Maple isn't intended for plotting) and don't support typeset math. This isn't usually an issue. I'm not familiar with the way MapleTA uses these drivers, but you might consider re-asking this question on the MapleTA forum, where somebody might know another approach.

David Clayworth Maplesoft GUI Developer

GRID won't actually help you much here, as it still gives you a rectangular grid of points. The only advantage over listcontplot is that you can specify the range of the grid. You still have to place your data points at regular intervals.

I really don't recommend using the GRID structure. The PLOT and PLOT3D structures (i.e. all the uppercase commands) are actually the internal data structures of the Maple plot, so by using them you are bypassing a lot of error checking and other functionality that is built in to the commands in the plots and plottools packages. They are only intended as a last resort for things you can't do any other way.

If a rectangular grid of points works for you, provided the ranges can be adjusted, then what I recommend is a combination of listcontplot and the plottools transform command. This allows you to do linear transforms on your plot. Here is an example that scales the output of listcontplot, dividing its x and y by 3:

with(plots); with(plottools);
t := transform((x, y) -> [x/3, y/3]); 
c := listcontplot([seq([seq(sin(x*y/(5*5)), x = -15 .. 15)], y = -15 .. 15)]); 
display(t(c));

You can make a 3D contour plot in a similar way

t := transform((x, y,z) -> [(1/3)*x, (1/3)*y,z/3]); c := listcontplot3d([seq([seq(sin(x*y/(5*5)), x = -15 .. 15)], y = -15 .. 15)]); display(t(c));

If your dataset does not have rectangular structure at all then you will need to look at the thread mentioned by jakubi above, or maybe CurveFitting[ArrayInterpolation].

David Clayworth Maplesoft GUI Developer

Hello gamsiz I'm afraid the contourplot function is not capable of doing what you want. Contourplot is designed only to take functions as inputs and not data. There is a command "listcontplot" which does take data. It assumes that the data is on a uniformly spaced grid, which yours fortunately is. Unfortunately it does not recognise any coordinate systems other than cartesian. You will be able to create a contour plot in which the r and theta values form the x and y of a cartesian plot. What you need to do is use readdata to read the data; then extract the third value from each list entry; split the resulting single list into a list of lists, with one list for each r value. Then if you input that stricture to listcontplot you should get a contour plot. BUT the plot will be rectangular and it may be distorted (it will have its aspect ratio changed). This may be enough for you, and it will certainly be better than nothing. The alternative is probably to find a way of transforming your data to a function defined over the area you are interested in. How you would do that depends very much on the data you have.

David Clayworth Maplesoft GUI Developer

A more general way of doing this is to plot the separate functions and then combine them into a single graph using <code>display</code>. Here is a simple example:

with(plots);

p1:=plot(sin(x),x=0..Pi);

p2:=plot(cos(x),x=Pi..2*Pi);

display(p1,p2);

David Clayworth Maplesoft GUI Developer

Maybe you could tell us what you have managed to do so far and what was wrong with it?

David Clayworth Maplesoft GUI Developer

I don't believe that either of these are doing what you want to be done.

surfdata considers the data to be an nx3 array of z values and plots each z values as though on an nx3 grid.

polygonplot3d considers the data to be a single polygon, with the data defining the vertices. Since the data are not ordered correctly for a polygon (and don't in fact define a single polygon) you will get a polygon that overlaps itself in many places and occupies space that it should not. It's only because the data you have are roughly in a plane that the polygon looks like anything useful at all.

David Clayworth Maplesoft GUI Developer

Robert is right that there is a slight advantage to using GIF rather than JPG (it's inherent in the formats). The important thing is the size though. If you use the regular context menus or plot menu the plot is exported at the size it appears in the worksheet. Often this is not good enough for export purposes. You can use the 'plotsetup' approach Robert suggests, or simply increase the size of the plot in the worksheet by dragging it, export it, and then return the plot to its usual size.

 

David Clayworth Maplesoft GUI Developer

It should be noted that the plot commands are designed to give a graphical representation of a function, and are not intended to have mathematical operations done on them. If you were looking for the maximum of the function, the graph you plot might not have a point exactly at the maximum, and then the results Robert gives (while a correct answer to the question asked) will be only approximate as a maximum of the function.

Finding the maximum value of your function can be done by

maximize(x*exp(-x), x = 0 .. 2);

Finding the x value at which the maximum occurs is done by finding the zero of the derivative:

solve(diff(x*exp(-x), x) = 0, x);

David Clayworth Maplesoft GUI Developer

You can plot multiple points, in multiple colours if required, with a single pointplot. Note the nested lists.

 with(plots);
 pointplot([[0, 0], [1, 1]], color = [red, blue]);

 

David Clayworth Maplesoft GUI Developer

If you were working with 2D plots (and assuming you have Maple 11 or later) you could use the numeric formatting features to control the way tickmarks look (bring up help and enter "formatting" as a topic).

3D does not yet support numeric formatting. However you can control your tickmarks exactly using the custom tickmarks option. For this add to your plot an option like

tickmarks=[default,default,[1000="1000",1500="1500",2000="2000"]]

This will give you the exact strings you specify as the labels on the tickmarks.

David Clayworth Maplesoft GUI Developer

I had a look at the plots and while the straight sections of the graphs look odd, they do actually represent the functions as calculated. You can check this by using the menus to change the plot style to "Point". That will draw a symbol everywhere Maple has calculated a value for the graph. The points are dense enough that the graph is accurate (unless your function fluctuates very quickly). I'm unable to comment on the correctness of the functions.

David Clayworth Maplesoft GUI Developer

1 2 3 4 5 6 7 Page 3 of 8