GLE - Graphics Layout Engine

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.

GLE Home

GLE Manual

In [0]:
)lib GLE
   GraphicsLayoutEngine is now explicitly exposed in frame initial 
   GraphicsLayoutEngine will be automatically loaded when needed from 
      /home/kfp/IPyNB/GLE.NRLIB/GLE

Out[0]:

In [1]:
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
Out[1]:
                                                                   Type: Void
In [2]:
drawSurface(sin(x)*cos(y-x),x=-1..1,y=-1..1,"surf1")
Warning: HyperTeX macro table not found
   Compiling function drawSurface with type (Expression(Integer),
      SegmentBinding(Integer),SegmentBinding(Integer),String) -> 
      FileName 
   Compiling function %C with type (DoubleFloat,DoubleFloat) -> 
      DoubleFloat 
   Transmitting data...
Out[2]:
In [3]:
drawSurface(besselJ(4,sqrt(x^2+y^2)),x=-1..1,y=-1..1,"surf2")
   Compiling function %E with type (DoubleFloat,DoubleFloat) -> 
      DoubleFloat 
   Transmitting data...
Out[3]:
In [4]:
sombrero(r)==2*besselJ(1,%pi*r)/%pi/r
Out[4]:
                                                                   Type: Void
In [5]:
drawSurface(sombrero(sqrt(x^2+y^2)),x=-2..2,y=-2..2,"surf3")
   Compiling function sombrero with type Expression(Integer) -> 
      Expression(Integer) 
   Compiling function %F with type (DoubleFloat,DoubleFloat) -> 
      DoubleFloat 
   Transmitting data...
Out[5]:
In [6]:
drawSurface(x^2-y^4,x=-3..3,y=-1..1,"surf4")
   Compiling function drawSurface with type (Polynomial(Integer),
      SegmentBinding(Integer),SegmentBinding(Integer),String) -> 
      FileName 
   Compiling function %H with type (DoubleFloat,DoubleFloat) -> 
      DoubleFloat 
   Transmitting data...
Out[6]:
In [7]:
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
Out[7]:
                                                                   Type: Void
In [8]:
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")
   Compiling function drawContour with type (Expression(Integer),
      SegmentBinding(Integer),SegmentBinding(Integer),List(Float),
      String) -> FileName 
   Compiling function %J with type (DoubleFloat,DoubleFloat) -> 
      DoubleFloat 
   Transmitting data...
Out[8]:
In [9]:
drawContour(x^2+y^2,x=-1..1,y=-1..1,[0.0,0.2,0.4,0.6,0.8],"cont2")
   Compiling function drawContour with type (Polynomial(Integer),
      SegmentBinding(Integer),SegmentBinding(Integer),List(Float),
      String) -> FileName 
   Compiling function %L with type (DoubleFloat,DoubleFloat) -> 
      DoubleFloat 
   Transmitting data...
Out[9]:
In [10]:
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
Out[10]:
                                                                   Type: Void
In [11]:
gleCpOpt("color","magenta");
gleCpOpt("title","My Title");
gleCpOpt("colormap","true");
gle3dOpt("size","22 22");
Out[11]:
                                                   Type: Table(String,String)
                                                   Type: Table(String,String)
                                                   Type: Table(String,String)
                                                   Type: Table(String,String)
In [12]:
drawContour2(sin(x)*cos(y-x),x=-1..1,y=-1..1,0.0..1.0,0.2,"cont3")
   Compiling function drawContour2 with type (Expression(Integer),
      SegmentBinding(Integer),SegmentBinding(Integer),Segment(Float),
      Float,String) -> FileName 
   Compiling function %N with type (DoubleFloat,DoubleFloat) -> 
      DoubleFloat 
   Transmitting data...
Out[12]:
In [13]:
drawContour2(x^2/3+y^2/5,x=-1..1,y=-1..1,0.0..1.0,0.2,"cont3")
   Compiling function drawContour2 with type (Polynomial(Fraction(
      Integer)),SegmentBinding(Integer),SegmentBinding(Integer),Segment
      (Float),Float,String) -> FileName 
   Compiling function %P with type (DoubleFloat,DoubleFloat) -> 
      DoubleFloat 
   Transmitting data...
Out[13]:
In [14]:
gleCpOpt("title","Another title");
gleCpOpt("colormap","true");
gle3dOpt("size","22 22");
gleCpOpt("cmap-args","120 120");
gleCpOpt("color","yellow");
Out[14]:
                                                   Type: Table(String,String)
                                                   Type: Table(String,String)
                                                   Type: Table(String,String)
                                                   Type: Table(String,String)
                                                   Type: Table(String,String)
In [15]:
drawContour2(sin(x-y)*cos(y^2),x=-1..1,y=-1..1,0.0..1.0,0.1,"cont4")
   Compiling function %R with type (DoubleFloat,DoubleFloat) -> 
      DoubleFloat 
   Transmitting data...
Out[15]:
In [16]:
drawContour2(x^2/2+y^2/7,x=-1..1,y=-1..1,0.0..1.0,0.1,"cont5")
   Compiling function %T with type (DoubleFloat,DoubleFloat) -> 
      DoubleFloat 
   Transmitting data...
Out[16]:
In [17]:
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
Out[17]:
                                                                   Type: Void
In [18]:
drawGraph(x^2,x=-1..1,"graph1")
   Compiling function drawGraph with type (Polynomial(Integer),
      SegmentBinding(Integer),String) -> FileName 
   Compiling function %V with type DoubleFloat -> DoubleFloat 
Out[18]:
In [19]:
drawGraph(sin(x)^2/x^2*cos(x),x=-2..2,"graph2")
   Compiling function drawGraph with type (Expression(Integer),
      SegmentBinding(Integer),String) -> FileName 
   Compiling function %X with type DoubleFloat -> DoubleFloat 
Out[19]:
In [20]:
gle2dOpt("math","math");
gle2dOpt("dn color","d1 color red");
gle2dOpt("title","title _"Bessel Function J_7_"");
Out[20]:
                                                   Type: Table(String,String)
                                                   Type: Table(String,String)
                                                   Type: Table(String,String)
In [21]:
drawGraph(besselI(7,x) ,x=-3..3,"graph3")
   Compiling function %Y with type DoubleFloat -> DoubleFloat 
Out[21]:
In [22]:
gle2dOpt("math","math");
gle2dOpt("dn color","d1 color red");
gle2dOpt("title","");
Out[22]:
                                                   Type: Table(String,String)
                                                   Type: Table(String,String)
                                                   Type: Table(String,String)
In [23]:
drawGraph(exp(-x)*sin(x) ,x=-3..3,"graph4")
   Compiling function %BA with type DoubleFloat -> DoubleFloat 
Out[23]:
In [24]:
gle2dOpt("math","");
gle2dOpt("dn color","d1 color magenta");
gle2dOpt("title","title _"The Gamma Function_"");
gle2dOpt("xaxis","xaxis grid");
Out[24]:
                                                   Type: Table(String,String)
                                                   Type: Table(String,String)
                                                   Type: Table(String,String)
                                                   Type: Table(String,String)
In [25]:
drawGraph(Gamma(x),x=0.5..3.0,"graph5")
   Compiling function drawGraph with type (Expression(Integer),
      SegmentBinding(Float),String) -> FileName 
   Compiling function %BB with type DoubleFloat -> DoubleFloat 
Out[25]:
In [26]:
gle2dOpt("yaxis","yaxis grid");
gle2dOpt("dn color","d1 color orange");
Out[26]:
                                                   Type: Table(String,String)
                                                   Type: Table(String,String)
In [27]:
drawGraph(Gamma(x),x=0.5..3.0,"graph6")
   Compiling function %BC with type DoubleFloat -> DoubleFloat 
Out[27]:
In [ ]: