Some examples using gle.spad.
GLE (Graphics Layout Engine) is a graphics scripting language designed for creating publication quality figures (e.g., a chart, plot, graph, or diagram). It supports various chart types (including function plot, histogram, bar chart, scatter plot, contour plot, color map, and surface plot) through a simple but flexible set of graphing commands. More complex output can be created by relying on GLE's scripting language, which is full featured with subroutines, variables, and logic control. GLE relies on LaTeX for text output and supports mathematical formulae in graphs and figures. GLE's output formats include EPS, PS, PDF, JPEG, and PNG. GLE is licenced under the BSD license.
)lib GLE
drawSurface(f,xr,yr,name) ==
gle3d(f,xr,yr,name)
cmd:=concat ["system gle -d png ","_"",name,".gle_""]
png:=(concat [name,".png"])::FileName
systemCommand(cmd)
return png
drawSurface(sin(x)*cos(y-x),x=-1..1,y=-1..1,"surf1")
drawSurface(besselJ(4,sqrt(x^2+y^2)),x=-1..1,y=-1..1,"surf2")
sombrero(r)==2*besselJ(1,%pi*r)/%pi/r
drawSurface(sombrero(sqrt(x^2+y^2)),x=-2..2,y=-2..2,"surf3")
drawSurface(x^2-y^4,x=-3..3,y=-1..1,"surf4")
drawContour(f,xr,yr,L,name) ==
gleCp(f,xr,yr,L,name)
cmd:=concat ["system gle -d png ","_"",name,".gle_""]
png:=(concat [name,".png"])::FileName
systemCommand(cmd)
return png
drawContour(sin(x)*cos(y-x),x=-1..1,y=-1..1,[-0.8,-0.6,-0.4,-0.2,0.0,0.2],"cont1")
drawContour(x^2+y^2,x=-1..1,y=-1..1,[0.0,0.2,0.4,0.6,0.8],"cont2")
drawContour2(f,xr,yr,r,step,name) ==
gleCp(f,xr,yr,r,step,name)
cmd:=concat ["system gle -d png ","_"",name,".gle_""]
png:=(concat [name,".png"])::FileName
systemCommand(cmd)
return png
gleCpOpt("color","magenta");
gleCpOpt("title","My Title");
gleCpOpt("colormap","true");
gle3dOpt("size","22 22");
drawContour2(sin(x)*cos(y-x),x=-1..1,y=-1..1,0.0..1.0,0.2,"cont3")
drawContour2(x^2/3+y^2/5,x=-1..1,y=-1..1,0.0..1.0,0.2,"cont3")
gleCpOpt("title","Another title");
gleCpOpt("colormap","true");
gle3dOpt("size","22 22");
gleCpOpt("cmap-args","120 120");
gleCpOpt("color","yellow");
drawContour2(sin(x-y)*cos(y^2),x=-1..1,y=-1..1,0.0..1.0,0.1,"cont4")
drawContour2(x^2/2+y^2/7,x=-1..1,y=-1..1,0.0..1.0,0.1,"cont5")
drawGraph(f,xr,name) ==
gle2d(f,xr,name)
cmd:=concat ["system gle -d png ","_"",name,".gle_""]
png:=(concat [name,".png"])::FileName
systemCommand(cmd)
return png
drawGraph(x^2,x=-1..1,"graph1")
drawGraph(sin(x)^2/x^2*cos(x),x=-2..2,"graph2")
gle2dOpt("math","math");
gle2dOpt("dn color","d1 color red");
gle2dOpt("title","title _"Bessel Function J_7_"");
drawGraph(besselI(7,x) ,x=-3..3,"graph3")
gle2dOpt("math","math");
gle2dOpt("dn color","d1 color red");
gle2dOpt("title","");
drawGraph(exp(-x)*sin(x) ,x=-3..3,"graph4")
gle2dOpt("math","");
gle2dOpt("dn color","d1 color magenta");
gle2dOpt("title","title _"The Gamma Function_"");
gle2dOpt("xaxis","xaxis grid");
drawGraph(Gamma(x),x=0.5..3.0,"graph5")
gle2dOpt("yaxis","yaxis grid");
gle2dOpt("dn color","d1 color orange");
drawGraph(Gamma(x),x=0.5..3.0,"graph6")