2746
Programmatically controlling plots within an ENVI plot window
Note: This help article applies only to Classic ENVI, and not to the new interface introduced with ENVI 5.
Users can programmatically create ENVI plots using ENVI_PLOT_DATA, but the routines to control those plots are not documented. This help article discusses using SP_REMOVE_ALL to remove all plots within an existing plot window and SP_IMPORT to put new plots in an existing plot window.
When you create a plot window via ENVI_PLOT_DATA, one of the keywords to this call is BASE=base. All subsequent control of the plots in the new plot window stems from this base.
After creating an ENVI plot window with ENVI_PLOT_DATA, you can use SP_REMOVE_ALL to remove all plots from that window:
ENVI_PLOT_DATA, x, y, BASE=base
SP_REMOVE_ALL, base
You can also use SP_IMPORT to add a new plot into the plot window:
SP_IMPORT, base, X, Y
Here the X and Y keywords indicate the data which will be plotted into the specified plot window. The Y keyword can be a 2D array (nplots,npoints) to import multiple plot curves at once.
If this is the first plot put into the window, then the automatic scaling of the plot axes will occur. If there are already other plots in the window (or if other plots were in the window at some point), then when this plot is added to the window, the original scaling of axes will be kept intact.
Keywords to SP_IMPORT that will override default properties for the incoming plot include:
NAME, COLOR, LSTYLE, THICK, PSYM, SYMSIZE
If the Y plot variable is an array (specifying multiple plots), then all of these property keywords will also need to be arrays. There are other keywords to SP_IMPORT, but it is expected that they rarely would be needed.
Please note that SP_REMOVE_ALL and SP_IMPORT are not documented routines and are unsupported. Therefore, there is some risk involved in using them. Nevertheless, these routines have been around for a long time, and are unlikely to change in the forseeable future.