Re: legend not working with symcat [message #68541 is a reply to message #68540] |
Wed, 04 November 2009 06:21   |
maurya
Messages: 16 Registered: February 2009
|
Junior Member |
|
|
On 4 Nov, 14:41, David Fanning <n...@dfanning.com> wrote:
> maurya writes:
>> The routine 'legend' is not working with the function 'symcat' for
>> the following test program.
>
>> ;;;;;;;;;===============================
>> pro legend_test
>
>> set_plot,'win'
>
>> window,0,xs=600,ys=500
>
>> n=12
>> xx=findgen(200)
>> for i=0,n-1 do begin
>> ii=i+1
>> yy=sin(xx*!dtor*ii*0.2)
>> if (i eq 0) then plot,yy,yr=[0,1.1],psym=symcat(i),/yst $
>> else oplot,yy,psym=symcat(i),symsize=0.6,nsum=2
>> endfor
>
>> lines=indgen(n)
>> item='p='+string(lines,format='(i2.2)')
>> legend,item,psym=symcat(lines)
>
>> stop
>> end
>> ;;;;;;;;;;;;================================================ ======
>
>> Can anyone help.
>
> Probably not. The problem is that SymCat is not "vectorized"
> in this way, and with good reason. Most of the symbols SymCat
> creates have to be built one-at-a-time with USERSYM. Then
> selected with the symbol index 8. So, if it was vectorized,
> you would certainly end up with a vector filled mostly with
> 8's.
>
> IDL> symbols = IntArr(10)
> IDL> FOR j=0,9 DO symbols[j] = SymCat(j + 10)
> IDL> Print, symbols
> 10 8 8 8 8 8 8 8 8 8
>
> In other words, the symbol created by USERSYM is "ephemeral"
> and can only be used for a short time. Well, until the *next*
> symbol is defined.
>
> The only way to fix this, as far as I can tell, would be
> to modify legend.pro to call SymCat whenever is creates a
> symbol.
>
> On lines 425-427, in which PLOTS is being used
> to draw the symbol in the legend with PSYM, I changed
> "psym=psym[i]" to "psym=SymCat(psym[i]" and I changed
> your example program call from this:
>
> legend, item, psym=SymCat(lines)
>
> To this:
>
> legend, item, psym=lines
>
> And all works as you expect.
>
> Wayne would have to confirm that this is the only place a change
> would have to be made. But I think he could add this to legend
> and gain access to 35 more symbols then he has now and not be
> worried by backward compatibility at all. ;-)
>
> Cheers,
>
> David
>
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming:http://www.dfanning.com/
> Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Thanks David,
I changed the "legend.pro" as you have suggested. Now, it is working
for n<=10 only. For larger values of n>10 it is giving following
error:
PLOTS: PSYM (plotting symbol) out of range
When I commentated the line 223 (on_error, 2), the program stop at the
line 425-427 where the correction is made. Although, according to your
"symcat" program it should work for 46 symbols. However, I need only
for n<=12.
RAM
|
|
|