Return to Ferret FAQ


Fill between two curves


Question:

How can I fill between two curves?

Example:


[Output Graphic]

Solution:

A script has been contributed by Wiemin Wang and Steve Hankin that uses the POLYGON command to fill between two curves, or a curve and a constant value. The text at the start of the script explains its arguments.

Use the script, fill_between.jnl It is one of the go scripts included with Ferret. Then, for example,
   yes? DEFINE AXIS/Z=1:100:1 z100
   yes? LET zz = z[gz=z100]
   yes? LET a = SIN(zz/10)- zz/50
   yes? LET b = 3 + COS(zz/4)
   yes? PLOT a,b
   yes? GO fill_between POLY/OVER/NOLABEL/PALETTE=blue a z100 b

Continuing, to make the figure on the right above, we fill between the curve defined by variable b and the vertical line at 3.0. Overlay the curves a and b again for clarity.

   yes? GO fill_between POLY/OVER/NOLABEL/PALETTE=yellow b z100 3.
   yes? PLOT/OVER/NOLAB/COLOR=black a
   yes? PLOT/OVER/NOLAB/COLOR=red b


Last modified: March 1, 2004