LabVIEW for Everyone: Graphical Programming Made Easy and Fun (3rd Edition)
So what do you do if you want to plot three variables against each other, instead of just two? If you're using Windows, you can use the ActiveX 3D Graph Controls, which we'll discuss next. On all versions of LabVIEW, you can also make an intensity plot. Intensity charts and graphs display three dimensions of data on a 2D plot by using color to display values of the third dimension of data (the "Z" values). Like the waveform chart, the intensity chart features a scrolling display, while the intensity graph display is fixed. Intensity plots are extremely useful for displaying patterned data such as terrain, where color represents altitude over a two-dimensional area, or temperature patterns, where color represents temperature distribution (see Figure 8.49). Figure 8.49. Intensity Graph (top) and Intensity Chart (bottom), which display color as a third dimension
Intensity plots function much like two-dimensional charts and graphs in most ways, with the addition of color to represent the third variable. A color scale is available so you can set and display the color mapping scheme. Intensity graph cursor displays also include a Z value. Intensity charts and graphs accept 2D arrays of numbers, where each number in the array is a color value. The indices of each array element represent the plot location for that color. Not only can you define the mapping of numbers to colors using the color scale (which works like a color ramp, if you've played with that), but you can also do it programmatically using property nodes (Chapter 12, "Instrument Control in LabVIEW," will tell you all about them). The simple example in Figure 8.50 shows a 3 x 4 array plotted on an intensity graph. The colors mapped are blue (1.0), green (2.0), and red (3.0). Figure 8.50. An intensity graph displaying a 2D array of intensity values as colors
To assign a color to a value on the color scale, pop up on the corresponding marker and select Marker Color>> ("markers" are the numeric displays on the Z scale legend). The Z scale of intensity charts and graphs has Arbitrary Marker Spacing by default, so you can alter the "gradient" of colors by dragging a marker with the Operating tool. Create new markers by selecting Add Marker from the Color Scale pop-up menu, and then drag them to a desired location and assign a new color. If you want to learn more about intensity charts and graphs, we suggest playing around with them. You can also look in LabVIEW's online documentation for more exact instructions. Activity 8-5: The Intensity Graph
In this activity, you will look at a VI that displays wave interference patterns. This VI will also show you how the intensity graph maps its input 2D array to the display.
For more examples of intensity plots, open some of the VIs that ship with LabVIEW in examples\general\graphs\intgraph.llb. You can also check out Simulation of Tomography and Heat Equation Example in examples\analysis\mathxmpl.llb (see Figure 8.53). Figure 8.53. Simulation of Tomography.vi front panel
3D Graphs
For true three-dimensional graphs, LabVIEW for Windows[1] Professional Version offers a 3D Surface Graph, 3D Parametric Graph, and 3D Curve Graph from the Graph palette. [1] If you're a Mac or Linux user and feel left out, let National Instruments know you'd like this feature across all platforms.
These 3D graphs are only for Windows, and are not present in the Base package of LabVIEW. Figures 8.54 and 8.55 show a VI's front panel and block diagram that presents an example of a "doughnut"called a torusplotted on the 3D Parametric Graph control. Unlike the previous charts and graphs you've seen, 3D graphs don't have a simple block diagram terminal; they actually use special subVI functions that are automatically created when you drop a 3D graph on the front panel. (You can find the Torus.vi in the LabVIEW examples, using the NI Example Finder.) Figure 8.54. Torus.vi front panel showing a 3D toroidal "doughnut" surface plot . . . mmmm doughnuts!
Figure 8.55. Torus.vi block diagram
The three types of 3D graphs can all plot in three dimensions, but each one works slightly differently: A 3D Surface Graph plots a simple surface from the z matrix (see Figure 8.56). The surface is modified by the x and y vectors that cause the surface to shift in relation to the x and y planes. It accepts one 2D array and the two optional 1D arrays. Figure 8.56. 3D Surface Graph
3D Parametric Surface plots a surface in terms of x, y, and z surfaces (see Figure 8.57). It takes in three 2D arrays or matrices that specify each of the x, y, and z planes. Figure 8.57. 3D Parametric Surface
3D Curve describes a line in terms of x, y, and z points (see Figure 8.58). This VI has three 1D arrays or vectors inputs that specify each point in the plot. Figure 8.58. 3D Curve
3D graphs can be more complicated than the simple charts and graphs you've worked withthey are really an advanced topic, so we won't say more about them here; we just wanted to let you know they are there if you need them. You can browse LabVIEW's 3D graph examples to get an idea of how to use them.
These 3D graphs are ActiveX controls and contain more functionality than is exposed by the 3D graph VIs. As you will learn in Chapter 16, "Connectivity in LabVIEW," you can use property and invoke nodes to access these additional properties and methods. |
Категории