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

Home » Public Forums » archive » plot function and legend in a for loop
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: plot function and legend in a for loop [message #91853 is a reply to message #91851] Fri, 04 September 2015 05:40 Go to previous messageGo to previous message
andreas.brunn is currently offline  andreas.brunn
Messages: 3
Registered: September 2015
Junior Member
On Friday, September 4, 2015 at 2:25:37 PM UTC+2, andrea...@gmx.de wrote:
> Dear all,
>
> I'm trying to create an indefinite number of lines in one plot. Additionally the goal is to additionally get a legend.
>
> I was trying to do this somehow like this:
>
> p=plot(spec(0), name=names(0))
>
> for i=1,n_elements(spec-1) do p1=plot(spec(i), name=names(i), /over)
>
>
> l=legend(target=[p,p1])
>
> doing that, not unsurprisingly, I get only the first and last name in the legend.
>
> Is there a way to mitigate the issue other than adding if statements like
>
> if n_elements(spec) gt 2 then p3=plot ....
> if n_elements(spec) gt 3 then p4=plot ....
>
> with this way, no matter how many of these lines I add I would at some day end up with some plots not being plotted ;-)
>
> thanks a lot and best regards
> Andreas

Ok I have tried the most obvious last and just got rid of the target keyword. In this case it did what I wanted from the beginning.
Nevertheless. Is there a way to address properties explicitly in cases like that?

thanks again,
Andreas
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Coyote Graphics "stuck" on Helvetica when outputting to PostScript?
Next Topic: backprojection

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

Current Time: Wed Oct 08 15:49:04 PDT 2025

Total time taken to generate the page: 0.00183 seconds