Custom Plot Functions

This topic describes how to write custom ENVI plot functions in IDL. Plot functions provide a method for applying user-specified transforms to data in any ENVI plot window. You can choose a custom plot function from the Y: drop-down menu in any ENVI plot window.

Custom plot functions receive the input y values of an (x,y) plot and return the transformed y values to be plotted. Plot functions only operate on the y-axis data; the x-axis remains the same.

See the following sections:

Write Custom Plot Functions

The basic structure of a custom plot function looks like this:

FUNCTION My_Function_Name_custom_plot_function, $

  x, y, BBL_ARRAY=bblArray, _REF_EXTRA=refExtra

 

COMPILE_OPT idl2

 

  ; plot function here

 

END

Where:

The plot function can do anything to the incoming data array as long as the number of Y elements does not change. The X values are also sent in to the function and may be used if needed.

Save the code to a .pro file in IDL, or use the IDL SAVE command to create a .sav file.

Deploy Custom Plot Functions

Place the .pro file in the directory specified by the Custom Code Directory preference. The default location is as follows, where x_x is the ENVI version number:

Windows: C:\Users\username\.idl\envi\custom_codex_x

Linux: /home/username/.idl/envi/custom_codex_x

Example

This simple example plots the natural log (alog) of image data values. Follow these steps:

  1. Start IDL and open a new IDL Editor window.
  2. Copy and paste the following code into the IDL Editor:
  3. FUNCTION Natural_Log_custom_plot_function, x, y, $

      _REF_EXTRA=refExtra

    COMPILE_OPT idl2

     

     Return, Alog(y)

     

    END

  4. Save the program as Natural_Log_custom_plot_function.pro to your custom code directory, described above.
  5. Start ENVI.
  6. Open and display the file qb_boulder_msi from your default ENVI installation path.
  7. Right-click anywhere in the image and select Profiles > Spectral. A Spectral Profile window appears.
  8. From the Y: drop-down list, select Natural Log. The natural log plot is displayed; for example: