example8.py :  » GUI » Biggles » python2-biggles-1.6.6 » examples » Python Open Source

Home
Python Open Source
1.3.1.2 Python
2.Ajax
3.Aspect Oriented
4.Blog
5.Build
6.Business Application
7.Chart Report
8.Content Management Systems
9.Cryptographic
10.Database
11.Development
12.Editor
13.Email
14.ERP
15.Game 2D 3D
16.GIS
17.GUI
18.IDE
19.Installer
20.IRC
21.Issue Tracker
22.Language Interface
23.Log
24.Math
25.Media Sound Audio
26.Mobile
27.Network
28.Parser
29.PDF
30.Project Management
31.RSS
32.Search
33.Security
34.Template Engines
35.Test
36.UML
37.USB Serial
38.Web Frameworks
39.Web Server
40.Web Services
41.Web Unit
42.Wiki
43.Windows
44.XML
Python Open Source » GUI » Biggles 
Biggles » python2 biggles 1.6.6 » examples » example8.py
#!/usr/bin/env python

import sys
sys.path.insert(1,'..')

import biggles
import numpy

#
# Create example 2-dimensional data set of two solitons colliding.
#
n = 64
x = numpy.arange( -10., 10., 20./n )
t = numpy.arange( -1., 1., 2./n )
z = numpy.zeros( (len(x),len(t)) )

for i in range(len(x)):
  for j in range(len(t)):
    z[i,j] = -12. * (3. + 4.*numpy.cosh(2.*x[i]-8.*t[j]) \
      + numpy.cosh(4.*x[i] - 64.*t[j])) / \
      (3.*numpy.cosh(x[i]-28.*t[j]) \
      + numpy.cosh(3.*x[i]-36.*t[j]))**2

#
# Make contour component.
#
c = biggles.Contours( z, x, t, color="red" )

#
# For fine-grained color control, the Contours component allows you to
# specify a function which returns the color applied to each contour line.
# The arguments passed to the function are:
#
#  i  integer index of contour (0,..,n-1)
#  n   total number of contours
#  z0  z value of contour
#  z_min  minimum z contour value
#  z_max  maximum z contour value
#
# The function should return a valid color, or None for the default.
#
# Here we show how to set every other contour to blue. The remaining 
# contours are drawn with the default color, defined above to be red.
#
def even_blue( i, n, z0, z_min, z_max ):
  if i % 2 == 0:
    return 0x0000ff
  return None

c.func_color = even_blue

#
# Similarly, Contours accepts similar functions for line type (.func_linestyle)
# and width (.func_linewidth). The arguments passed are the same.
#

#
# Make framed plot container and add contour component.
#
p = biggles.FramedPlot()
p.add( c )

#
# Output.
#
#p.write_img( 400, 400, "example8.png" )
#p.write_eps( "example8.eps" )
p.show()
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.