A Graph3d is a container for one or more three dimensional geometric objects (Surfaces, Mesh3ds, and/or Slices) as well as global information about the graph. It will accept one or a list of Plotter objects or Plotter identifiers, or will try to complete generic connection(s) of its own if asked to plot without having been given a plotter specification.
<object list> is one or a sequence of 3d geometric objects. It makes sense sometimes to graph several such objects on one plot. By means of linking two or more objects (see description below), it is possible though somewhat difficult in PyNarcisse to plot two or more objects with different 3d/4d options, palettes, etc. on the same graph. PyGist does not allow this; however, in mesh plots which mix isosurfaces and plane slices, PyGist allows a split palette option, which shades the isosurfaces as if from a light source, but colors plane slices according to the specified function.
A list of keyword arguments accepted by Graph3d is:
Graph3d objects inherit from base class Graph, as does Graph2d. The following methods are inherited from Graph: add_file, delete_file, add_plotter, delete_plotter, and change. See "Description" on page 75 for details. In addition, a Graph3d has the following methods which, except where noted, are similar to the Graph2d methods with the same names: new, add, delete, replace, change_plot, quick_plot, and plot.
Finally, Graph3d has two methods which have to do with real time animation of 3d plots. These methods are as follows:
move_light_source (<keylist>) The keyword arguments are:
nframes (default 30): the number of frames in the proposed movie.
angle (default 360 / nframes): the angle (in degrees) through which the light source rotates for each frame.
This method is not yet implemented in PyNarcisse.
rotate (<keylist>) The keyword arguments are:
axis (default [-1., 1., 0.]): the direction numbers of the axis about which the graph is rotated.
nframes (default 30): the number of frames in the proposed movie.
angle (default 360 / nframes): the angle (in degrees) through which the graph is rotated for each frame.
This method is not yet implemented in PyNarcisse.
The following keywords inherited from Graph have exactly the same behavior as described under Graph2d (See "Keyword Arguments" on page 77):
Up to four axes are possible in 3d and 4d plots : x, y, z or c (depending on whether we chose the option of switching z and c), and the right y axis (when the left and right sides of the plot have different y axis scales, with some objects plotted on one and some on another), so the specifications of axis characteristics are different from those for Graph2d. The axis characteristic keywords (primarily applicable to PyNarcisse, but see the next paragraph) are:
Each should be specified as a list of up to five items, in the order x, y, z, c, yr; items omitted from the right will be defaulted. axis_labels are strings; axis_limits are pairs of floats; and axis_scales are one of the two strings "lin" or "log".
PyGist does not currently support full axes display in 3d. Instead, it is capable of displaying a gnomon in the lower left corner of a 3d plot, i. e., a small representation showing the orientation of the three coordinate axes, with the labels in reverse video if they are pointed ``into'' the plane of the plot. These labels default to ``X'', ``Y'', and ``Z'', but the defaults can be overruled by the axis_labels keyword. PyGist will only use the first letter of each specified label, if longer than one letter. The keyword gnomon (if set to nonzero) turns on the gnomon display.
Another peculiarity of PyGist is its tendency to stretch the plotted surface so that it extends from edge to edge of the plotting area. The keywords x_factor and y_factor can be used to force the display to appear in proper perspective; in most cases leave x_factor alone, and set y_factor to 2.0. Both keywoirds default to 1.0.
Other keywords which are peculiar to Graph3d objects are:
phi = <integer value> specifies the angle that the line from the view point to the origin makes with the positive z axis. The angle is in degrees.
theta = <integer value> specifies the angle made by the projection of the line of view on the xy plane with the positive x axis. The angle is in degrees.
roll = <integer value> specifies the angle of rotation of the graph around the line from the origin to the view point. The angle is measured in the positive direction, i. e., if your right thumb is aligned outwards along the line from the origin to the view point, then your fingers curl in the positive direction. The angle is in degrees. (This keyword is not available in PyGist, and will be ignored if supplied.)
distance = <integer value> specifies the distance of the view point from the origin. This is an integer between 0 and 20. 0 makes the distance infinite; otherwise the smaller the number, the closer you are. This number does not affect the size of the graph, but rather the amount of distortion in the picture (the closer you are, the more distortion).
The following keywords are applicable only in PyNarcisse:
link = 0 or 1: Used to link surfaces of different 3d options. normally all surfaces in a graph will have the same 3d options. This value should be set to 1 if you want to graph two or more surfaces with different 3d options. otherwise multiple surface graphs will appear with the options of the last surface specified. This may not always work as expected, since successive objects in a linked Graph are plotted on top of whatever is in the current window. That may not be where they are positioned; e. g., it would be easy to have an object that is really behind another be drawn on top of it.
connect = 0 or 1: set to 1 for graphs of more than one 3d object to provide better hidden line removal. Must not be used with link.
sync = 0 or 1: set to 1 to synchronize with Narcisse before plotting the next graph. Keeps graphs sent in rapid succession from becoming garbled. Defaults to 1; set it to 0 if you don't have a timing problem.
The following lighting keywords are applicable only in PyGist:
ambient = <value> is a light level (arbitrary units) that is added to every surface independently of its orientation. High values of this argument cause the surface to appear to glow with its own light, making it so bright as to lose contrast. Low values of this argument mean that reflected and diffuse light are more important in visualizing the surface.
diffuse = <value> is a light level which is proportional to cos (theta), where theta is the angle between the surface normal and the viewing direction, so that surfaces directly facing the viewer are bright, while surfaces viewed edge on are unlit (and surfaces facing away, if drawn, are shaded as if they faced the viewer, so that if we are looking at the inside of a surface, it will look properly three-dimensional).
specular = <value>
spower = <value>
sdir = <value>
specular = S_LEVEL is a light level proportional to a high power spower = N of 1 + cos (alpha), where alpha is the angle between the specular reflection angle and the viewing direction. The light source for the calculation of alpha lies in the direction sdir = XYZ (a 3 element vector) in the viewer's coordinate system at infinite distance. You can have ns light sources by making S_LEVEL, N, and XYZ (or any combination) be vectors of length ns (ns-by-3 in the case of XYZ).
The four parameters ambient, diffuse, specular, and spower act together to produce interesting effects. if diffuse and specular are both 0, then the surface will not be reflective, and all three dimensional appearance will be lost. specular and spower together determine how reflective the surface is; large spower with specular not 0 gives small, bright highlights with most of the surface appearing black. As spower decreases, the highlights become somewhat larger and darker portions of the surface become lighter. If diffuse is not zero but specular and ambient are zero, then the surface will appear shaded gently, brighter on the side(s) toward the light source(s), but not highly reflective. The user is encouraged to experiment to find the desired effect.
split = 0 or 1 (default 1) If 1, causes the palette to be split when both planes and isosurfaces are present in a graph, so that isosurfaces are shaded according to current light settings, while plane sections of the mesh are colored according to a specified function. (The lower half of the palette is grey scale, and the upper half is (usually) rainbow.
All of the plots illustrated in this example are of the following surface; it is an interesting symmetric surface with a peak and a valley.
In each case, the title describes how the surface is displayed. We have set the y_factor keyword to 2.0 so that the surface will show in proper perspective; otherwise it would be stretched out from border to border in the vertical direction.
The next example is interesting in that it shows a back-lit surface.
The user may recall this example. An imploding sphere has been decomposed into an unstructured (but hexahedral) mesh. The data is read in from a pdb file as follows:
Now we build a Mesh3d object from the data:
Create three Plane objects with which to perform cross sections:
In this example, we will illustrate how to set up a graph with a moving light source. The light source will apparently move over the surface in real time. You will have to take our word for this; the next two figures show different views of the surface as the light progresses.
Imagine the light source as moving from right to left just behind the viewer.
We cannot show you the actual rotation in these pages, but we shall show you a couple of different snapshots of the rotating surface. This example consists of a couple of isosurfaces in a mesh, each sliced horizontally and vertically, with parts discarded so that we can see inside the figure, and a portion of one of the slicing planes. The isosurfaces are shaded in greyscale as if by a light shining over the viewer's right shoulder, and the polygons of the portion of the slicing plane are colored using the rainbow palette by the values of the same function that was used to perform the isosurface slicing. This figure illustrates the so-called ``split palette'', where half of the palette is set to greyscale colors and is used to shade isosurfaces, while the other half is set to colors used to plot function values on plane slices.
The edges of the polygons on the plane slice are also shown. The figure and the code generating it begin below.
The following code computes the coordinates of the mesh, the function c defined on it, and then creates the Mesh3d object.
The following code sequence performs the slicing. We do not specify opt_3d for the isosurfaces, since with the split palette option they will automatically be shaded.
The code which generates the rotating figure is given below. We change the x_factor and y_factor of g1 so that the figure will appear smaller.
Snapshots of the rotating figure are shown on the next page.