-
Notifications
You must be signed in to change notification settings - Fork 1
Home
maxima-draw2d-plus is a collection of additional functions for the draw2d package of the maxima CAS, a free symbolic mathematics package, see:
http://maxima.sourceforge.net/
http://riotorto.users.sourceforge.net/gnuplot/index.html
To load the package, put the file vector.mac in a location where maxima can find it and type on the maxima prompt:
(%i01) batch("vector.mac");
The package draw2d is automatically loaded when you load vector.mac. You can now use the new command Vectorplot.
The syntax is:
Vectorplot([fx(x,y),fy(x,y)],[xmin,xmax],[ymin,ymax],[optional-arguments])
(%i02) Vectorplot([y,-x],[-2,2],[-2,2]);
A vector plot of the vector field [y,-x] will be drawn, using 10x10 vectors on an equidistant grid. The vectors are colored by their norm (sqrt(VxVx + VyVy)). Vectorplot expects 2 variables in the vector field and will rank the variables alphabetically. The first variable (alphabetically) will be associated with the horizontal axis and the second variable will be associated with the vertical axis. This behavior can be changed with the parameters xvar and yvar.
(%i02) Vectorplot([w,-v],[-2,2],[-2,2]);
(%i02) Vectorplot([v,-w],[-2,2],[-2,2]);
(%i02) Vectorplot([v,-w],[-2,2],[-2,2],xvar=w,yvar=w);
You can save images to file by writing to a file terminal, e.g. jpg or png:
(%i02) Vectorplot([y,-x],[-2,2],[-2,2],terminal=png);
The file will be saved in the default file maxima_out.png. You can change the filename using the keyword filename:
(%i02) Vectorplot([y,-x],[-2,2],[-2,2],terminal=png,filename="vectorplot");
The file extension is automatic. A higher quality image is obtained using the terminal pngcairo:
(%i02) Vectorplot([y,-x],[-2,2],[-2,2],terminal=pngcairo,filename="vectorplotcairo");
Notice the smoother vectors compared to the jagged lines in the previous figure.
The default number of vectors in X and Y direction is 10, so by default Vectorplot will draw 100 vectors. You can change this using the optional argument vectorpoints:[Nx,Ny]:
(%i02) Vectorplot([y,-x],[-2,2],[-2,2],vectorpoints:[25,25],terminal=pngcairo,filename="densevectorplotcairo");