Hello Dae-Kyu,
This is not a very straight-forward process to get the graphics names from the current graphics windows. The best bet would be no not lose your object references to your plots. Here is an extension to your code that you provided:
pro plot_name_get_from_window
compile_opt idl2
;close all plot windows
ireset, /no_prompt
win = window()
p1 = plot(/test, /current)
p2 = plot(/test, sym='D', name='temp', $
/current, /overplot)
;save plot references with a lsit
all_plots = list()
all_plots.add, p1
all_plots.add, p2
;remove p1 an p2 referencs
delvar, p1
delvar, p2
;but i can change the "p1" and "p2" property through "win" object.
wait, .5
all_plots[0].thick = 2
wait, .5
all_plots[1].sym_color = 'red'
;find the window dimensions
win_dim = win.dimensions
;find all itmes in the window
;this will also return axis objects
selected = win.HitTest(floor(.5*win_dim[0]), floor(.5*win_dim[1]),$
dimensions = win_dim)
;make an ordered hash for plot names and their references
plot_names = orderedhash(keys, values)
;make a list with just plot references
plot_references = list()
;get all of the plot references from the objects in the graphics window
for i = 0, n_elements(selected) - 1 do begin
;get names of each plot object only if they are plots
if (obj_class(selected[i]) eq 'PLOT') then begin
selected[i].getproperty, name = temp
plot_names[temp] = selected[i]
plot_references.add, selected[i]
endif
endfor
;print the names and object references
print, plot_names
wait, .5
plot_references[1].sym_color = 'black'
wait, .5
plot_references[0].thick = 1
end
|