/* [wxMaxima batch file version 1] [ DO NOT EDIT BY HAND! ]*/ /* [ Created with wxMaxima version 17.10.0 ] */ /* [wxMaxima: title start ] test plot2d with wxmaxima [wxMaxima: title end ] */ /* [wxMaxima: comment start ] file plot2dtest.wxm, Dec. 2017 Ted Woollett Maxima by Example http://web.csulb.edu/~woollett [wxMaxima: comment end ] */ /* [wxMaxima: comment start ] 1. test default number-color association with [style, [lines,6]] syntax expect: 1 = blue, 2 = red, 3 = green, 4 = majenta, 5 = black, 6 = cyan, 7 = blue, 8 = red, ... A draw2d version of the following plot2d plot is (You only need to load the draw package once per session.) load(draw); draw2d (points_joined = true, line_width = 4,point_size=0, xrange = [-2,20], yrange = [-2,8], color=blue, key = "1", points ([[0,0],[0,5]]), color=red, key = "2",points ([[2,0],[2,5]]), color = green, key = "3", points ([[4,0],[4,5]]), color = magenta, key = "4", points ([[6,0],[6,5]]), color = black, key = "5",points ([[8,0],[8,5]]), color = cyan, key = "6",points ([[10,0],[10,5]]), color = blue, key = "7",points ([[12,0],[12,5]]), color = red, key = "8",points ([[14,0],[14,5]]), xtics = none,ytics = none,axis_bottom = false, axis_top = false,axis_left = false,axis_right = false)$ [wxMaxima: comment end ] */ /* [wxMaxima: input start ] */ plot2d( [ [discrete,[[0,0],[0,5]]], [discrete,[[2,0],[2,5]]], [discrete,[[4,0],[4,5]]],[discrete,[[6,0],[6,5]]], [discrete,[[8,0],[8,5]]],[discrete,[[10,0],[10,5]]], [discrete,[[12,0],[12,5]]],[discrete,[[14,0],[14,5]]] ], [style, [lines,6]], [x,-2,20], [y,-2,8], [legend,"1","2","3","4","5","6","7","8"], [xlabel," "], [ylabel," "], [box,false],[axes,false])$ /* [wxMaxima: input end ] */ /* [wxMaxima: comment start ] 2. test number-color association in plot2d using [lines, nwidth, ncolor] syntax [wxMaxima: comment end ] */ /* [wxMaxima: input start ] */ plot2d( [ [discrete,[[0,0],[0,5]]], [discrete,[[2,0],[2,5]]], [discrete,[[4,0],[4,5]]],[discrete,[[6,0],[6,5]]], [discrete,[[8,0],[8,5]]],[discrete,[[10,0],[10,5]]], [discrete,[[12,0],[12,5]]],[discrete,[[14,0],[14,5]]] ], [style, [lines,6,1],[lines,6,2],[lines,6,3], [lines,6,4],[lines,6,5],[lines,6,6],[lines,6,7], [lines,6,8]], [x,-2,20], [y,-2,8], [legend,"1","2","3","4","5","6","7","8"], [xlabel," "], [ylabel," "], [box,false],[axes,false])$ /* [wxMaxima: input end ] */ /* [wxMaxima: comment start ] 3. test colors with [style,[lines,6]], [color, c1, c2, ...] syntax A draw2d version of the following plot2d plot is: (You only need to load the draw package once per session.) load(draw); draw2d (points_joined = true, line_width = 4,point_size=0, xrange = [-2,20], yrange = [-2,8], color=blue, key = "blue", points ([[0,0],[0,5]]), color=red, key = "red",points ([[2,0],[2,5]]), color = green, key = "green", points ([[4,0],[4,5]]), color = magenta, key = "magenta", points ([[6,0],[6,5]]), color = black, key = "black",points ([[8,0],[8,5]]), color = cyan, key = "cyan",points ([[10,0],[10,5]]), color = blue, key = "blue",points ([[12,0],[12,5]]), color = red, key = "red",points ([[14,0],[14,5]]), xtics = none,ytics = none,axis_bottom = false, axis_top = false,axis_left = false,axis_right = false)$ [wxMaxima: comment end ] */ /* [wxMaxima: input start ] */ plot2d( [ [discrete,[[0,0],[0,5]]], [discrete,[[2,0],[2,5]]], [discrete,[[4,0],[4,5]]],[discrete,[[6,0],[6,5]]], [discrete,[[8,0],[8,5]]],[discrete,[[10,0],[10,5]]], [discrete,[[12,0],[12,5]]],[discrete,[[14,0],[14,5]]] ], [style,[lines,6]], [color, blue, red, green, magenta, black, cyan,blue,red], [x,-2,20], [y,-2,8], [legend,"blue","red","green","magenta","black","cyan","blue","red"], [xlabel," "], [ylabel," "], [box,false],[axes,false])$ /* [wxMaxima: input end ] */ /* [wxMaxima: comment start ] 4. test default number-(point type) association with [style,[points,5,1]], syntax Ideally, there should be 13 distinct point types for plot2d; but recent Maxima versions of wxMaxima only give 6 point types using Windows 7, but 13 using Windows XP. One can also use numbers to choose point types using draw2d; there are 16 point types if we include dot (0) as a point type. The corresponding names are given incorrectly in the Maxima manual under the topic 'point_type' in the draw section of the manual. Note that plot2d also has a syntax involving the plot_type, as in [plot_type, bullet,circle,...]. draw2d ( xrange = [-0.2,1], yrange = [-0.2,0.7], color = blue, point_size = 2, point_type = 0, key = "0", points([[-0.1,0.5]]), point_type = 1, key = "1", points([[0,0.5]]), point_type = 2, key = "2", points ([[0.1,.5]]), point_type = 3, key = "3", points ([[0.2,.5]]), point_type = 4, key = "4", points ([[0.3,.5]]), point_type = 5, key = "5", points ([[0.4,0.5]]), point_type = 6, key = "6", points ([[0.5,.5]]), point_type = 7, key = "7", points ([[0.6,.5]]), point_type = 8, key = "8", points ([[0.7,.5]]), point_type = 9, key = "9", points ([[0,0]]), point_type = 10, key = "10", points ([[0.1,0]]), point_type = 11, key = "11", points ([[0.2,0]]), point_type = 12, key = "12", points ([[0.3,0]]), point_type = 13, key = "13", points ([[0.4,0]]), point_type = 14, key = "14", points ([[0.5,0]]), point_type = 15, key = "15", points ([[0.6,0]]), point_type = 16, key = "16", points ([[0.7,0]]), xtics = none,ytics = none,axis_bottom = false, axis_top = false,axis_left = false,axis_right = false)$ [wxMaxima: comment end ] */ /* [wxMaxima: input start ] */ plot2d([ [discrete,[[0,.5]]],[discrete,[[0.1,.5]]],[discrete,[[0.2,.5]]],[discrete,[[0.3,.5]]], [discrete,[[0.4,.5]]],[discrete,[[0.5,.5]]], [discrete,[[0.6,.5]]],[discrete,[[0.7,.5]]], [discrete,[[0,0]]],[discrete,[[0.1,0]]], [discrete,[[0.2,0]]],[discrete,[[0.3,0]]], [discrete,[[0.4,0]]],[discrete,[[0.5,0]]],[discrete,[[0.6,0]]],[discrete,[[0.7,0]]] ], [style,[points,5,1]], [xlabel," "],[ylabel," "], ['x,-0.2,1],['y,-0.2,0.7], [box,false],[axes,false], [legend,"1 ","2 ","3 ","4 ","5 ","6 ","7 ","8 ","9 ","10 ","11 ","12 ","13 ","14 ","15 ","16 "])$ /* [wxMaxima: input end ] */ /* [wxMaxima: comment start ] 5. test number-(point type) association with [style, [points,5,1,1], [points,5,1,2],..] syntax. this uses [point,nradius,ncolor,ntype ] syntax. Again should be 13 distinct point types ideally. [wxMaxima: comment end ] */ /* [wxMaxima: input start ] */ plot2d([ [discrete,[[0,.5]]],[discrete,[[0.1,.5]]],[discrete,[[0.2,.5]]],[discrete,[[0.3,.5]]], [discrete,[[0.4,.5]]],[discrete,[[0.5,.5]]], [discrete,[[0.6,.5]]],[discrete,[[0.7,.5]]], [discrete,[[0,0]]],[discrete,[[0.1,0]]], [discrete,[[0.2,0]]],[discrete,[[0.3,0]]], [discrete,[[0.4,0]]],[discrete,[[0.5,0]]], [discrete,[[0.6,0]]],[discrete,[[0.7,0]]] ], [style, [points,5,1,1], [points,5,1,2], [points,5,1,3], [points,5,1,4], [points,5,1,5], [points,5,1,6], [points,5,1,7], [points,5,1,8], [points,5,1,9], [points,5,1,10], [points,5,1,11], [points,5,1,12], [points,5,1,13], [points,5,1,14], [points,5,1,15], [points,5,1,16] ], [xlabel," "],[ylabel," "], ['x,-0.2,1],['y,-0.2,0.7], [box,false],[axes,false], [legend,"1 ","2 ","3 ","4 ","5 ","6 ","7 ","8 ","9 ","10 ","11 ","12 ","13 ","14 ","15 ","16 "])$ /* [wxMaxima: input end ] */ /* [wxMaxima: comment start ] 6. test alternative point type syntax using [style,[points,5,1]], [point_type, t1,t2, ...], in which t1, t2,...are spelled out descriptions of line types, such as bullet, box, etc. This method should achieve all 13 distinct point types. [wxMaxima: comment end ] */ /* [wxMaxima: input start ] */ plot2d([ [discrete,[[0,.5]]],[discrete,[[0.1,.5]]],[discrete,[[0.2,.5]]],[discrete,[[0.3,.5]]], [discrete,[[0.4,.5]]],[discrete,[[0.5,.5]]], [discrete,[[0.6,.5]]],[discrete,[[0.7,.5]]], [discrete,[[0,0]]],[discrete,[[0.1,0]]], [discrete,[[0.2,0]]],[discrete,[[0.3,0]]], [discrete,[[0.4,0]]],[discrete,[[0.5,0]]],[discrete,[[0.6,0]]],[discrete,[[0.7,0]]] ], [style,[points,5,1]], [point_type, bullet,circle,plus,times,asterisk,box,square,triangle,delta, wedge,nabla,diamond,lozenge,bullet,circle,plus], [xlabel," "],[ylabel," "], ['x,-0.2,1],['y,-0.2,0.7], [box,false],[axes,false], [legend,"bullet ","circle ","plus ","times ","asterisk ","box ", "square ","triangle ","delta ","wedge ","nabla ", "diamond ","lozenge ","bullet ","circle ","plus "])$ /* [wxMaxima: input end ] */ /* [wxMaxima: comment start ] 7. test indep. range control with plot2d ( sin(u),['u,0,%pi/2],['x, -0.2, 1.8] ) in which the parameter u controls the range of the drawing, and the parameter x describes the canvas width. Some versions of Maxima will object to this syntax. If you want to stick with a version of Maxima in which this syntax results in an error, you can achieve the desired plot by using the draw package. (You only need to load the draw package once per session.) load (draw)$ draw2d ( xrange = [-0.2, 1.8],yaxis = true, color = blue, explicit (sin(u),u,0,%pi/2), xlabel = "u", ylabel = "sin(u)")$ [wxMaxima: comment end ] */ /* [wxMaxima: input start ] */ plot2d ( sin(u),['u,0,%pi/2],['x, -0.2, 1.8] )$ /* [wxMaxima: input end ] */ /* [wxMaxima: comment start ] 8. Another more complicated range control and canvas width plot2d example. A draw package version corresponding to the following plot2d plot is: draw2d ( xrange = [-0.2, 2.5], yrange = [-1, 4], xaxis=true,yaxis=true, line_width = 5, color= black,key="u^2", explicit (u^2,u,0,2), color= red,key = "u^3", explicit (u^3,u,0,2), xlabel = "u")$ [wxMaxima: comment end ] */ /* [wxMaxima: input start ] */ plot2d( [u^2,u^3],['u,0,2], ['x, -.2, 2.5], [style, [lines,5,5],[lines,5,2]], ['y,-1,4] )$ /* [wxMaxima: input end ] */ /* [wxMaxima: comment start ] 9. test independent control of range, canvas width, grid, key position, title. In some versions of Maxima, the separate range control will result in an error, and in some versions, the 'set grid' argument in the gnuplot_preamble string will not return a plot with a grid. One can still toggle a grid on and off with the button on the gnuplot window. A draw2d version of the following plot2d plot is: draw2d ( xrange=[-8,8],yrange = [-3.5,2],grid = true, xaxis = true, xaxis_width = 2, xaxis_type = dots, xaxis_color = brown, yaxis = true, yaxis_width = 2, yaxis_type = dots, yaxis_color = brown, line_width = 4, color = blue, key = "u*sin(u)", explicit(u*sin(u),u,-4,4), color = red, key = "cos(u)", explicit(cos(u),u,-4,4), user_preamble = "set key bottom center")$ [wxMaxima: comment end ] */ /* [wxMaxima: input start ] */ plot2d([ u*sin(u),cos(u)],['u,-4,4] ,['x,-8,8], [style,[lines,5]], [gnuplot_preamble,"set grid; set key bottom center; set title 'Two Functions';"])$ /* [wxMaxima: input end ] */ /* [wxMaxima: comment start ] 10. Simple parametric plot using t as the parametric parameter. A draw2d version of the following plot2d plot is (may not be round) draw2d (xrange = [-sqrt(2),sqrt(2)], xaxis = true, yaxis = true, color = blue, parametric (cos(t),sin(t),t,0,2*%pi), xlabel = "cos(t)", ylabel = "sin(t)")$ To get a round circle with draw2d, add the option: proportional_axes = xy draw2d (xrange = [-sqrt(2),sqrt(2)], xaxis = true, yaxis = true, color = blue, parametric (cos(t),sin(t),t,0,2*%pi), xlabel = "cos(t)", ylabel = "sin(t)", proportional_axes = xy)$ [wxMaxima: comment end ] */ /* [wxMaxima: input start ] */ plot2d ([parametric,cos(t),sin(t),[t,0,2*%pi]],[x,-sqrt(2),sqrt(2)])$ /* [wxMaxima: input end ] */ /* [wxMaxima: comment start ] 11. test parametric plot using t as the parametric plot parameter, and with discrete points added. this should work with any version of Maxima. a draw2d version of the following plot2d plot is draw2d ( xrange=[-3,4],yrange = [-1,40], xaxis = true, xaxis_width = 2, xaxis_type = solid, xaxis_color = red, yaxis = true, yaxis_width = 2, yaxis_type = solid, yaxis_color = brown, line_width = 4, color = black, key = " ", parametric (2*cos(t),t^2,t,0,2*%pi), point_type = filled_circle, point_size = 2, color = blue, key = "t = 0", points ([[2,0]]), color = red,key = "t = pi/2", points ([[0,(%pi/2)^2]]), color = green,key = "t = pi", points ([[-2,%pi^2]]), color = magenta,key = "t = 3*pi/2", points ([[0,(3*%pi/2)^2]]))$ [wxMaxima: comment end ] */ /* [wxMaxima: input start ] */ obj_list : [ [parametric, 2*cos(t),t^2,['t,0,2*%pi]], [discrete,[[2,0]]],[discrete,[[0,(%pi/2)^2]]], [discrete,[[-2,%pi^2]]],[discrete,[[0,(3*%pi/2)^2]]] ]$ style_list : [style, [lines,4,5],[points,5,1,1],[points,5,2,1], [points,5,3,1],[points,5,4,1]]$ legend_list : [legend, " ","t = 0","t = pi/2","t = pi", " t = 3*pi/2"]$ plot2d( obj_list, ['x,-3,4], ['y,-1,40],style_list, [xlabel,"X = 2 cos( t ), Y = t ^2 "], [ylabel, " "] ,legend_list )$ /* [wxMaxima: input end ] */ /* [wxMaxima: comment start ] 12. can we use th as the parameter in a parametric plot using plot2d? In some versions of Maxima (such as 5.40.0 and 5.41.0), this will result in an error. A draw2d version of the following plot2d plot is: draw2d (xrange = [-sqrt(2),sqrt(2)], xaxis = true, yaxis = true, color = blue, parametric (cos(th),sin(th),th,0,2*%pi), xlabel = "cos(th)", ylabel = "sin(th)")$ [wxMaxima: comment end ] */ /* [wxMaxima: input start ] */ plot2d ([parametric,cos(th),sin(th),[th,0,2*%pi]],[x,-sqrt(2),sqrt(2)])$ /* [wxMaxima: input end ] */ /* [wxMaxima: comment start ] wxMaxima build info from windows xp 32bit ver. 5.41.0 sbcl download wxbuild_info()$ => wxMaxima version: 17.10.0 Maxima version: 5.31.2 Maxima build date: 2013-10-07 23:05:06 Host type: i686-pc-mingw32 System type: NIL NIL NIL Lisp implementation type: GNU Common Lisp (GCL) Lisp implementation version: GCL 2.6.8 On windows XP box, this version of wxMaxima produced 13 distinct point types, use of set grid inside gnuplot_preamble produced a grid, and the symbol th works as a parametric plot parameter. wxMaxima version 17.05.0 assoc with maxima ver 5.40.0 sbcl on windows xp showed same behavior. [wxMaxima: comment end ] */ /* [wxMaxima: input start ] */ wxbuild_info()$ /* [wxMaxima: input end ] */ /* [wxMaxima: comment start ] You will find a different Lisp version used if you are using Windows 7 (64 bit) or Windows 10 (64 bit) implementations. [wxMaxima: comment end ] */ /* Maxima can't load/batch files which end with a comment! */ "Created with wxMaxima"$