comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » turn a string value into variable name
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: turn a string value into variable name [message #94472 is a reply to message #94471] Fri, 02 June 2017 02:59 Go to previous messageGo to previous message
Markus Schmassmann is currently offline  Markus Schmassmann
Messages: 129
Registered: April 2016
Senior Member
On 06/02/2017 12:48 AM, laura.hike@gmail.com wrote:
> So now I want to do this in order to use a loop to add lines to a plot and then make a legend. I need the plot names to all be different so I can use them in the "target" argument, but I can otherwise make the plot commands identical, e.g.,
>
> p1 = plot(xbin, pdf, color = linecolors[nsea], thick = 2, name = seanames[nsea], /overplot)
>
> Based on David's comment, I tried
>
> execute('p5 = plot(xbin, pdf, color = linecolors[nsea-1], thick = 2, name = seanames[nsea-1], /overplot)')
>
> but this didn't do anything except return a "1". I'm really not excited about putting in a plot command (with an 'if' statement' for each of the lines I want to overplot.

I don't see why you'd use an EXECUTE here, try the code below

pp=objarr(n_lines)
for nsea=0,n_lines-1 do if <condition> then pp[nsea]=plot( xbin, pdf, $
color = linecolors[nsea-1], thick = 2, name = seanames[nsea-1], $
/overplot )
l=legend(target=pp)

If this doesn't help, please explain in more detail what you want to do,
it's now fully clear from your post.

Good Luck, Markus

PS: The main topic of this thread is mostly obsolete as of IDL 8.0 with
the introduction of HASH
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: IDL-python bridge issue for MacOS Sierra 10.12.2 (Library not loaded: libpython2.7.dylib)
Next Topic: Image registration

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 13:52:48 PDT 2025

Total time taken to generate the page: 0.00435 seconds