NCL Website header

NCL > Application examples > Basic examples

XyPlot example 16

Drawing multiple lines with different Y axes.

This example is created using HLU C library calls, HLU FORTRAN library calls, or NCL. It demonstrates how to create an XyPlot that has three different y axes. The names of the source files for this example are xy16c.c, xy16f.f, and xy16n.ncl.

Discussion

This example reads an ASCII file with 4 variables: lon, u, v, and t. The variables u, v, and t are plotted with 3 separate y axes.

In this example, each of the three variables are assigned their own Y axis and scales by creating three distinct XyPlot objects. The first object is given a full grid and has its Y axis scale on the left. The second object has no grid and the Y axis scale on the right of the first grid. The third object's viewport is made wider than the first two and its X axis is scaled so that the data end at the right grid boundary of the first object. Only the Y axis on the right is drawn for the third object. The curves and the Y axis scales are color coordinated so you can tell which curve goes with which scale.

There is no resource file with this example.

Creating the plot using HLUs

The HLU C program that generates this plot is called xy16c.c.

Creating the plot using HLU FORTRAN library calls

The HLU FORTRAN program that generates this plot is called xy16f.f.

Creating the plot using NCL

The NCL script that generates this plot is called xy16n.ncl.

The data

The data for this plot is from a file called "xy.asc".

How to run this example

The examples are installed in the following locations:

  • $NCARG_ROOT/lib/ncarg/hluex/xyplot/xy16c.c
  • $NCARG_ROOT/lib/ncarg/hluex/xyplot/xy16f.f
  • $NCARG_ROOT/lib/ncarg/nclex/xyplot/xy16n.ncl
The ASCII data file is installed in the following location:

  • $NCARG_ROOT/lib/ncarg/data/asc/xy.asc
You can copy this example and run it by typing "ng4ex xy16c", "ng4ex xy16f", or "ng4ex xy16n". A copy of the source file will be placed in your current working directory. The source code will be compiled and automatically run for you.