NCL > Application examples > Basic examples
Basic example 2
DiscussionThis module discusses how to size and position an NCAR Graphics plot using HLU C library calls, HLU FORTRAN library calls, and the NCAR Command Language. The example produces two frames that are drawn into an X Window.
The first frame of the example shows how to set the viewport (an object's bounding box) for an object using the vpXF, vpYF, vpWidthF, and vpHeightF resources. vpXF and vpYF are resources that specify the location of the left and top edge, respectively, of a viewport window. The values are specified in Normalized Device Coordinates (NDCs), such that the lower-left corner of the frame corresponds to the coordinate point (0,0), and the upper-right corner corresponds to the coordinate point (1,1). The vpWidthF and vpHeightF resources specify the width and height, respectively, of the viewport. These values are also specified in NDCs.
The second frame of the example shows how to draw multiple plots in a single frame. This is accomplished by drawing the first object, then resetting the viewport to specify a different plot location and size, then drawing the object again. These steps can be repeated multiple times to draw multiple plots on a single frame.
This example does not use any data and is therefore more useful for instruction rather than for creating useful graphical output. A detailed discussion about how to create the plot appears in the comments of the source code for the example.