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

Home » Public Forums » archive » Re: What am I doing wrong with al_legend?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: What am I doing wrong with al_legend? [message #78713] Tue, 13 December 2011 13:14
Avian is currently offline  Avian
Messages: 24
Registered: October 2011
Junior Member
That did it! David, even when you're sick, you're incredibly helpful - thanks! I've seen a few of those types of problems in procedures floating around lately from various sources.
Re: What am I doing wrong with al_legend? [message #78714 is a reply to message #78713] Tue, 13 December 2011 13:12 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Brian Wolven writes:

> I think this is a case where the keyword arguments are being passed by reference rather than value, then modified in the legend routine, which propagates back to the calling routine. I'm not using the cg* and al* flavors of these routines, but had something similar happen with an older version of legend recently. Your modification is one way to work around the problem.

I think it really has to do with the fact that keyword
values get "frozen" by necessity when they are added
to cgWindow. This code, for example, worked perfectly
well in a normal IDL graphics window. But, when added to
cgWindow, the PSYM value is frozen at 8, meaning use the
user defined symbol, and because there is *only* one user
defined symbol allowed at any particular time, it uses
the last one.

The work-around is to put any of these "dynamic"
determinations of keyword or parameter values inside
the program "command" that is being executed. That
way the actual value can be determined when the command
is executed from inside cgWindow.

In other words, let AL_LEGEND figure out what symbol
to use internally, rather than telling it what symbol
to use from outside the program.

Or, something like that. It hurts my head to think
about it. :-(

Cheers,

David


--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: What am I doing wrong with al_legend? [message #78715 is a reply to message #78714] Tue, 13 December 2011 12:52 Go to previous message
Brian Wolven is currently offline  Brian Wolven
Messages: 94
Registered: May 2011
Member
I think this is a case where the keyword arguments are being passed by reference rather than value, then modified in the legend routine, which propagates back to the calling routine. I'm not using the cg* and al* flavors of these routines, but had something similar happen with an older version of legend recently. Your modification is one way to work around the problem.
Re: What am I doing wrong with al_legend? [message #78716 is a reply to message #78715] Tue, 13 December 2011 12:40 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
David Fanning writes:

> I do notice that if modify the call to cgPlotS on lines
> 481-483 by changing the PSYM keyword from this "psym=p_sym"
> to this "psym=psmi[i]", then things work correctly.

Let me try that sentence again!

I do notice that if I modify the call to cgPlotS on lines
481-483 by changing the PSYM keyword from this "psym=p_sym"
to this "psym=psymi[i]", then things work correctly.

Sorry for the fat fingers this morning. I'm sick with
a cold, and not moving very quickly.

Cheers,

David




--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: What am I doing wrong with al_legend? [message #78717 is a reply to message #78716] Tue, 13 December 2011 12:29 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
David Fanning writes:

> Well, that does change things, although I can't for the
> life of me think why. :-(
>
> If you do the overplot *after* the legend, things
> work OK:
>
> cgplot, cgdemodata(1), /window, yrange=[-100,100]
> clrs=['black','red','org5','blue','grn4',$
> 'orange','violet','dodger blue']
> sym=[16,16,16,16,16,16,16,16]
> legtxt = StrTrim(Indgen(8)+1)
> AL_legend,legtxt,psym=sym,color=clrs,$
> pos=[65,0.5],box=0,/WINDOW
> cgplot,cgdemodata(1)/2,psym=13,SYMSIZE=0.7, $
> color='blk5',/OVERPLOT,/ADDCMD
> END
>
> I'll have to look into this. I'll get back to you.

OK. Oddly enough, this is another manifestation
of a problem I described in a new article this
morning:

http://www.idlcoyote.com/cg_tips/wrongsym.php

In fact, I had no more than just published it when
I read your post this morning! I guess when a problem
is ready to be discovered, *everyone* discovers it at
about the same time. :-(

Anyhow, I think this is a problem with AL_LEGEND. I don't
fully understand how AL_LEGEND works (or I might offer to
take over support for the darn thing from Wayne!), but
I do notice that if modify the call to cgPlotS on lines
481-483 by changing the PSYM keyword from this "psym=p_sym"
to this "psym=psmi[i]", then things work correctly.

I think this might be the case of not fully implementing
the change to Coyote Graphics in AL_LEGEND.

Anyway, I'll discuss this with Wayne and see what, if
anything, we can do to fix it. :-)

Cheers,

David



--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: What am I doing wrong with al_legend? [message #78719 is a reply to message #78717] Tue, 13 December 2011 11:59 Go to previous message
Avian is currently offline  Avian
Messages: 24
Registered: October 2011
Junior Member
Thanks so much David - I should've thought about that overplot (although I have several - I'll do the legend first). Thanks!
Re: What am I doing wrong with al_legend? [message #78720 is a reply to message #78719] Tue, 13 December 2011 11:43 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Avian writes:

> Thanks - the last command I have before the al_legend command is this:
>
> cgplot,x,y+0.3,psym=13,SYMSIZE=0.7,color='blk5',/OVERPLOT,/A DDCMD,/WINDOW
>
> Do you think you could try an overplot like this before you call al_legend?

Well, that does change things, although I can't for the
life of me think why. :-(

If you do the overplot *after* the legend, things
work OK:

cgplot, cgdemodata(1), /window, yrange=[-100,100]
clrs=['black','red','org5','blue','grn4',$
'orange','violet','dodger blue']
sym=[16,16,16,16,16,16,16,16]
legtxt = StrTrim(Indgen(8)+1)
AL_legend,legtxt,psym=sym,color=clrs,$
pos=[65,0.5],box=0,/WINDOW
cgplot,cgdemodata(1)/2,psym=13,SYMSIZE=0.7, $
color='blk5',/OVERPLOT,/ADDCMD
END

I'll have to look into this. I'll get back to you.

Cheers,

David


--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: What am I doing wrong with al_legend? [message #78721 is a reply to message #78720] Tue, 13 December 2011 11:24 Go to previous message
Avian is currently offline  Avian
Messages: 24
Registered: October 2011
Junior Member
Thanks - the last command I have before the al_legend command is this:

cgplot,x,y+0.3,psym=13,SYMSIZE=0.7,color='blk5',/OVERPLOT,/A DDCMD,/WINDOW

Do you think you could try an overplot like this before you call al_legend?
Re: What am I doing wrong with al_legend? [message #78722 is a reply to message #78721] Tue, 13 December 2011 11:13 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Avian writes:

> I just updated to the latest Coyote Graphics on your site, updated al_legend, restarted IDL - no luck. So strange!
>
> David - are you also seeing the correct symbol=16 shape?

Apparently so. Here is the code I used to test it:

cgplot, cgdemodata(1), /window, yrange=[-100,100]
clrs=['black','red','org5','blue','grn4',$
'orange','violet','dodger blue']
sym=[16,16,16,16,16,16,16,16]
legtxt = StrTrim(Indgen(8)+1)
AL_legend,legtxt,psym=sym,color=clrs,$
pos=[65,0.5],box=0,/WINDOW


And here is the output:

http://www.idlcoyote.com/misc/al_legend_ex.png

Cheers,

David



--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: What am I doing wrong with al_legend? [message #78723 is a reply to message #78722] Tue, 13 December 2011 10:40 Go to previous message
Avian is currently offline  Avian
Messages: 24
Registered: October 2011
Junior Member
I just updated to the latest Coyote Graphics on your site, updated al_legend, restarted IDL - no luck. So strange!

David - are you also seeing the correct symbol=16 shape?
Re: What am I doing wrong with al_legend? [message #78726 is a reply to message #78723] Tue, 13 December 2011 10:20 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Avian writes:

> I'm trying to create a legend with al_legend, and I thought i was following all the rules, but I just can't get the symbols in the legend to come up as anything other than whatever symbol I just used to plot the last line of data with.
>
> In this example, legtxt is a 8-dimensional string array
>
> clrs=['black','red','org5','blue','grn4','orange','violet',' dodger blue']
> sym=[16,16,16,16,16,16,16,16]
> AL_legend,legtxt,psym=sym,color=clrs,pos=[65,0.5],box=0,/WIN DOW
>
> (I've also tried "colors" as the keyword instead of "color")
>
> All my symbols in the legend end up as the same color and shape as the command I last used on the plot to overplot data with. What am I missing?

Not sure. I'm certainly getting different colors in my
graphics window when I try your code. Are your Coyote
and NASA Astronomy Libraries up to date? This is the
usual (>85%) reason for difficulties. :-)

Cheers,

David



--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Coyote Graphics Updates
Next Topic: idl crash with ps_end and fixps

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

Current Time: Wed Oct 08 15:33:25 PDT 2025

Total time taken to generate the page: 0.00551 seconds