TD_PLOT Function Examples | Teradata Vantage - TD_PLOT Examples - Teradata Vantage

Database Unbounded Array Framework Time Series Functions

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Teradata Vantage
Release Number
17.20
Published
June 2022
Language
English (United States)
Last Update
2024-10-04
dita:mapPath
ncd1634149624743.ditamap
dita:ditavalPath
ruu1634160136230.ditaval
dita:id
ncd1634149624743

TD_PLOT Input Table OCEAN_BUOYS

ROW_I TD_TIMECODE BuoyID Salinity Temperature
1 2023-04-05 12:00:00 33 50 15.0
2 2023-04-05 12:00:00 33 51 22.0
3 2023-04-05 12:15:00 33 52 17.0
4 2023-04-05 12:15:00 33 53 17.5
5 2023-04-05 12:30:00 33 54 15.5

Example: TD_PLOT Call for Line Chart

This example specifies the chart to be a 1024x768 PNG. The plot is a line chart with a title named XY Plot. There is a single data series which is plotted using a red dashed line.

EXECUTE FUNCTION
TD_PLOT(
  SERIES_SPEC(
    TABLE_NAME(OCEAN_BUOYS),
    ROW_AXIS(SEQUENCE(SALINITY)),
    SERIES_ID(BuoyID),
    PAYLOAD (
      FIELDS(TEMPERATURE),
      CONTENT(REAL)
    )
  )
  WHERE BuoyID = 33,
  FUNC_PARAMS(
    TITLE('XY Plot'),
    PLOTS[(
      TYPE('line'),
      FORMAT('r--')
    )],
    WIDTH(1024),
    HEIGHT(768)
  )
);

TD_PLOT Output for Line Plot

Line Plot

Example: TD_PLOT Call Using ID_SEQUENCE

This example generates the same plot as the previous example. It uses ID_SEQUENCE instead of WHERE clause to specify the data series.

EXECUTE FUNCTION
TD_PLOT(
  SERIES_SPEC(
    TABLE_NAME(OCEAN_BUOYS),
    ROW_AXIS(SEQUENCE(SALINITY)),
    SERIES_ID(BuoyID),
    ID_SEQUENCE('[{"BuoyID":33}]'),
    PAYLOAD (
      FIELDS(TEMPERATURE),
      CONTENT(REAL)
    )
  ),
  FUNC_PARAMS(
    TITLE('XY Plot'),
    PLOTS[(
      TYPE('line'),
      FORMAT('r--')
    )],
    WIDTH(1024),
    HEIGHT(768)
  )
);

TD_PLOT Output for ID_SEQUENCE

ID_SEQUENCE Plot

Example: TD_PLOT Call for Wiggle Chart

EXECUTE FUNCTION
TD_PLOT(
   MATRIX_SPEC
   (
      TABLE_NAME(waveletTable),
      ROW_AXIS(SEQUENCE(x)),
      COLUMN_AXIS(SEQUENCE(y)),
      MATRIX_ID(ID),
      PAYLOAD
      (
         FIELDS(c),
         CONTENT(REAL)
      )
   ),
   FUNC_PARAMS
   (
      PLOTS[(
      TYPE('wiggle')
      )],
     IMAGE('png')
   )
);

TD_PLOT Output for Wiggle Chart

Wiggle Chart

Example: TD_PLOT Call for Composite Chart

Composite charts position the graphs top left, then down, then top right, and then down.

EXECUTE FUNCTION
TD_Plot
(
    SERIES_SPEC
    (
        TABLE_NAME(TimeSeriesDataSetsD4),
        ROW_AXIS(SEQUENCE(SeqNo)),
        SERIES_ID(DataSetID),
        PAYLOAD
        (
           FIELDS(Magnitude),
           CONTENT(REAL)
        )
    ) WHERE DataSetID=552,
    SERIES_SPEC
    (
        TABLE_NAME(ACF_RES_552),
        ROW_AXIS(SEQUENCE(ROW_I)),
        SERIES_ID(DataSetID),
        PAYLOAD (FIELDS(Magnitude, CONF_OFF_Magnitude),CONTENT(MULTIVAR_REAL) )
    ) WHERE DataSetID=552,
    SERIES_SPEC
    (
        TABLE_NAME(PACF_RES_552),
        ROW_AXIS(SEQUENCE(ROW_I)),
        SERIES_ID(DataSetID),
        PAYLOAD (FIELDS(Magnitude, CONF_OFF_Magnitude),CONTENT(MULTIVAR_REAL) )
    ) WHERE DataSetID=552,
    SERIES_SPEC
    (
        TABLE_NAME(PWRSPEC_RES),
        ROW_AXIS(SEQUENCE(ROW_I)),
        SERIES_ID(DataSetID),
        PAYLOAD
        (
           FIELDS(SPECTRAL_DENSITY_Magnitude),
           CONTENT(REAL)
        )
    )WHERE DataSetID=552,
    FUNC_PARAMS
    (
        LAYOUT(2,2),
        WIDTH(1920),
        HEIGHT(1080),
        TITLE('SAVINGS RATES STATIONARITY PANEL'),
        PLOTS[
            (
                ID(1),
                CELL(1,1),
                TITLE ('SAVINGS RATES DATASET TIME SERIES'),
                GRID(FORMAT('-')),
                TYPE('line'),
                MARKER('o'),
                LEGEND('best'),
                XLABEL('X SeqNo'),
                YLABEL('Y Magnitude')
            ),
            (   ID(2),
                CELL(1,2),
                TITLE ('SAVINGS RATES DATASET ACF RESULT SERIES'),
                TYPE('corr')
               ,XLABEL('X LAG')
               ,YLABEL('Y Magnitude')
            ),
            (   ID(3),
                CELL(2,1),
                TITLE ('SAVINGS RATES DATASET PACF SERIES'),
                TYPE('corr')
               ,XLABEL('X LAG')
               ,YLABEL('Y Magnitude')
            ),
            (
                ID(4),
                CELL(2,2),
                TYPE('line')
               ,MARKER('o')
               ,XLABEL('X ROW_I in W K_RADIANS')
              ,YLABEL('Y SPECTRAL DENSITY MAGNITUDE')
              ,TITLE ('SAVINGS RATES DATASET POWER SPECTRUM RESULTS')
              ,LEGEND('best')
              ,GRID(FORMAT('-'))
            )
        ]
    )
);

TD_PLOT Output for Composite Chart

TD_PLOT Composite