File: test.py

package info (click to toggle)
mathgl 8.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 248,044 kB
  • sloc: cpp: 87,365; ansic: 3,299; javascript: 3,284; pascal: 1,562; python: 52; sh: 51; makefile: 47; f90: 22
file content (16 lines) | stat: -rw-r--r-- 567 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# python test.py
from mathgl import *
dat = mglData()	# data to for plotting
dat.Create(30,40)
for i in range(0,30):
  for j in range(0,40):
    dat.SetVal(1/(1+(i-15)*(i-15)/9.+(j-20)*(j-20)/16.),i,j)
gr = mglGraph()     # class for plot drawing
gr.SetRanges(0,2,0,2,0,1)	# ranges of coordinates
gr.Rotate(50,60)	# rotate axis
gr.Light(True)		# enable lighting
gr.Surf(dat)		# plot surface
gr.Cont(dat,"y")	# plot yellow contour lines
gr.Axis()			# draw axis
gr.Puts(mglPoint(1,1,1.2),"\\i f = \\dfrac{1}{1+(5x-5)^2+(5y-5)^2}")
gr.WriteFrame("sample.png")	# save it