/[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 1189 - (show annotations)
Thu Jun 7 05:31:25 2007 UTC (12 years, 7 months ago) by jongui
File MIME type: text/x-python
File size: 1547 byte(s)
A Scalar Bar can now be displayed by creating an instance of a 'Legend'. The Scalar Bar can either show the scalar data range or vector data range. Corresponding examples and tests have also been added.
1 # Import the necessary modules.
2 from esys.pyvisi import Scene, DataCollector, Map, Camera, Legend, Contour
3 from esys.pyvisi import LocalPosition
4 from esys.pyvisi.constant import *
5 import os
6
7 PYVISI_EXAMPLE_MESHES_PATH = "data_meshes"
8 PYVISI_EXAMPLE_IMAGES_PATH = "data_sample_images"
9 X_SIZE = 500
10 Y_SIZE = 500
11
12 FILE_NAME = "phi_talus_lava.0099.vtu"
13
14 IMAGE_NAME = "legend.jpg"
15 JPG_RENDERER = Renderer.ONLINE_JPG
16
17 # Create a Scene.
18 s = Scene(renderer = JPG_RENDERER, num_viewport = 1, x_size = X_SIZE,
19 y_size = Y_SIZE)
20
21 # Create a DataCollector reading from a XML file.
22 dc1 = DataCollector(source = Source.XML)
23 dc1.setFileName(file_name = os.path.join(PYVISI_EXAMPLE_MESHES_PATH, \
24 FILE_NAME))
25
26 # Create a Contour.
27 ctr1 = Contour(scene = s, data_collector = dc1,
28 viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, cell_to_point = False,
29 outline = True)
30 ctr1.generateContours(8, -4.963259999999998, 86.277230000000003)
31 ctr1.setScalarRange(-4.963259999999998, 86.277230000000003)
32
33 # Create a Legend.
34 lg1 =Legend(scene = s, data_collector= dc1, viewport = Viewport.SOUTH_WEST,
35 lut = Lut.COLOR, legend = LegendType.SCALAR)
36 lg1.setOrientationToHorizontal()
37 lg1.setScalarRange(-4.963259999999998, 86.277230000000003)
38 lg1.setTitle(title = "Scalar Bar")
39 lg1.setPosition(LocalPosition(50, 5))
40
41 # Create a Camera.
42 cam1 = Camera(scene = s, viewport = Viewport.SOUTH_WEST)
43
44 # Read in one file one after another and render the object.
45 s.render(image_name = os.path.join(PYVISI_EXAMPLE_IMAGES_PATH,
46 IMAGE_NAME))

  ViewVC Help
Powered by ViewVC 1.1.26