X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 05 Jul 2015 06:37 AM by  anon
function graphic question
 2 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:
New Member


--
05 Jul 2015 06:37 AM
    hi here is simple example code win = window() p1 = plot(/test, /current) p2 = plot(/test, sym='D', name='temp', /over) ;lost p1 and p2 object.(is the object is correct?) p1 = 0 p2 = 0 ;but i can change the "p1" and "p2" property through "win" object. win['plot'].thick=2 win['temp'].sym_color='red' i think, the "p1" and "p2" properties saved in "win" object. so, how can i get the "name" property of losted "p1" and "p2" object from "win" object??

    Zachary Norman



    Basic Member


    Posts:173
    Basic Member


    --
    06 Jul 2015 02:57 PM
    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

    Deleted User



    New Member


    Posts:
    New Member


    --
    09 Jul 2015 03:52 AM
    Hi Zach The "hittest" method come in very handy. Thanks.
    You are not authorized to post a reply.