National Oceanic and
Atmospheric Administration
United States Department of Commerce

Overlaying a time series on a 2D plot

Overlaying a time series on a 2D plot


How can I plot a time series on top of a SHADE or CONTOUR plot?




This FAQ describes a situation that has been remedied in Ferret/PyFerret versions beginning with V7. In versions higher than that, you may overlay a time series on a 2-D plot with no further adjustments.


Previous to the above versions, in order successfully to overlay a time series plot over a 2-dimensionalplot with a time axis (a Hovmoller diagram) it is essential that thetime axis of the data passed to the SHADE or CONTOUR command be in unitsof HOURS.


These commands illustrate the problem and the work-around:

! define a 2D field in YT with a time axis in units of DAYS
DEFINE AXIS/T="1-JAN-1980":"1-JAN-1990":1/UNITS=DAYS tdays
DEFINE GRID/y=yax/t=tdays gg
LET my_var = 10*cos(T/2000)*EXP((-1)*y/20)

! make a Hovmoller plot
SHADE my_var

! (THIS WILL NOT WORK --> try to overlay a time series. The time scaling is off.)

PLOT/OVER my_var[Y=@loc:-4]

! If running Ferret v6.96 or PyFerret 1.2, the above PLOT/OVER command draws the line correctly, and we are done.

! But this will work around the problem
DEFINE AXIS/T="1-JAN-1980":"1-JAN-1990":24/UNITS=HOURS thours
SHADE my_var[GT=thours]
PLOT/OVER my_var[Y=@loc:-4]

The plot above was created with:

use ""

set region/x=40w/y=10n:60n
define axis/t="15-jan-1982":"15-dec-1983":24/units=hours thours
shade sst[gt=thours]
plot/over sst[y=30n]