/[escript]/trunk/doc/examples/pyvisi/legend.py
ViewVC logotype

Contents of /trunk/doc/examples/pyvisi/legend.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1210 - (show annotations)
Tue Jul 3 05:47:34 2007 UTC (13 years, 5 months ago) by jongui
File MIME type: text/x-python
File size: 1562 byte(s)
Made some minor changes.
1 """
2 Author: John Ngui, john.ngui@uq.edu.au
3 """
4
5 # Import the necessary modules.
6 from esys.pyvisi import Scene, DataCollector, Map, Camera, Legend, Contour
7 from esys.pyvisi import LocalPosition
8 from esys.pyvisi.constant import *
9 import os
10
11 PYVISI_EXAMPLE_MESHES_PATH = "data_meshes"
12 PYVISI_EXAMPLE_IMAGES_PATH = "data_sample_images"
13 X_SIZE = 500
14 Y_SIZE = 500
15
16 FILE_NAME = "phi_talus_lava.0099.vtu"
17 IMAGE_NAME = "legend.jpg"
18 JPG_RENDERER = Renderer.ONLINE_JPG
19
20 # Create a Scene.
21 s = Scene(renderer = JPG_RENDERER, num_viewport = 1, x_size = X_SIZE,
22 y_size = Y_SIZE)
23
24 # Create a DataCollector reading from a XML file.
25 dc1 = DataCollector(source = Source.XML)
26 dc1.setFileName(file_name = os.path.join(PYVISI_EXAMPLE_MESHES_PATH, \
27 FILE_NAME))
28
29 # Create a Contour.
30 ctr1 = Contour(scene = s, data_collector = dc1,
31 viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, cell_to_point = False,
32 outline = True)
33 ctr1.generateContours(8, -4.963259999999998, 86.277230000000003)
34 ctr1.setScalarRange(-4.963259999999998, 86.277230000000003)
35
36 # Create a scalar Legend.
37 lg1 =Legend(scene = s, data_collector= dc1, viewport = Viewport.SOUTH_WEST,
38 lut = Lut.COLOR, legend = LegendType.SCALAR)
39 lg1.setOrientationToHorizontal()
40 lg1.setScalarRange(-4.963259999999998, 86.277230000000003)
41 lg1.setTitle(title = "Scalar Bar")
42 lg1.setPosition(LocalPosition(50, 5))
43
44 # Create a Camera.
45 cam1 = Camera(scene = s, viewport = Viewport.SOUTH_WEST)
46
47 # Render the object.
48 s.render(image_name = os.path.join(PYVISI_EXAMPLE_IMAGES_PATH,
49 IMAGE_NAME))

  ViewVC Help
Powered by ViewVC 1.1.26