In [1]:
using GR
In [2]:
inline("svg")
Out[2]:
"svg"
In [3]:
srand(0)
xd = -2 + 4 * rand(100)
yd = -2 + 4 * rand(100)
zd = [xd[i] * exp(-xd[i]^2 - yd[i]^2) for i = 1:100]
Out[3]:
100-element Array{Any,1}:
  0.115956  
  0.104626  
 -0.102141  
 -0.162131  
 -0.133527  
 -0.0158458 
 -0.00585385
 -0.00815143
 -0.40581   
  0.0289944 
  0.0431185 
  0.0821909 
 -0.117182  
  ⋮         
  0.368894  
  0.266593  
 -0.00291179
 -0.0618072 
 -0.0143026 
 -0.0722932 
  0.0210994 
 -0.18766   
  0.175804  
 -0.0114644 
  0.421782  
  0.0922979 
In [4]:
setviewport(0.1, 0.95, 0.1, 0.95)
setwindow(-2, 2, -2, 2)
setspace(-0.5, 0.5, 0, 90)
setmarkersize(1)
setmarkertype(GR.MARKERTYPE_SOLID_CIRCLE)
setcharheight(0.024)
settextalign(2, 0)
settextfontprec(3, 0)
In [5]:
x, y, z = GR.gridit(xd, yd, zd, 200, 200)
h = linspace(-0.5, 0.5, 20)
Out[5]:
20-element Array{Float64,1}:
 -0.5      
 -0.447368 
 -0.394737 
 -0.342105 
 -0.289474 
 -0.236842 
 -0.184211 
 -0.131579 
 -0.0789474
 -0.0263158
  0.0263158
  0.0789474
  0.131579 
  0.184211 
  0.236842 
  0.289474 
  0.342105 
  0.394737 
  0.447368 
  0.5      
In [6]:
surface(x, y, z, 5)
contour(x, y, h, z, 0)
polymarker(xd, yd)
axes(0.25, 0.25, -2, -2, 2, 2, 0.01)
In [7]:
show()
Out[7]:
- 2.0 - 1.5 - 1.0 - 0.5 0 0.5 1.0 1.5 2.0 - 2.0 - 1.5 - 1.0 - 0.5 0 0.5 1.0 1.5 2.0
In [ ]: