Re: cgwindow and cgplot, bug? [message #80971] |
Fri, 27 July 2012 05:29 |
Mats Löfdahl
Messages: 263 Registered: January 2012
|
Senior Member |
|
|
Den fredagen den 27:e juli 2012 kl. 14:13:32 UTC+2 skrev David Fanning:
> Mats Löfdahl writes:
>
> > I just noticed a possible bug in cgwindow/cgplot. Here is a minimal example.
> >
> > The following lines make a plot with two data points represented as squares:
> >
> > cgwindow, /free
> > cgplot,/add,[1,2],[2,1], psym=symcat(6),xrange=[0,5],yrange=[0,5]
> >
> > If I add the following line:
> >
> > cgplot,/add,/over,[1,2],[3,2], psym=symcat(9)
> >
> > I get two more points as circles as expected - AND the two points from the first cgplot call are ALSO turned into circles! I've updated the coyote library (five minutes ago) but the problem persists.
> >
> > In a cgdisplay window and without the /add keyword, the plot comes out as expected.
>
> Yes, this is because keyword values are hard-coded when
> they are added to the cgWindow. When you say PSYM=SymCat(6),
> whatever SymCat(6) evaluates to is stored as the PSYM
> keyword. In this case, (in almost *every* case!) that
> value is 8. That happens to be the same value as
> SymCat(9).
>
> But, the solution is simple. Don't use SYMCAT here!!!
> If you don't use it, then the symbol value is NOT
> hard-coded, but is evaluated at the time the
> cgPlot command is executed.
>
> This problem is a result of writing the commands
> incorrectly. The proper way to write these commands
> is like this:
>
> cgWindow
> cgPlot, /add,[1,2],[2,1], psym=6, xrange=[0,5], yrange=[0,5]
> cgplot, /add, /over, [1,2],[3,2], psym=9
Ah, a little more attention is required when fixing up some older code.
Thanks and sorry about the noise!
/Mats
|
|
|
Re: cgwindow and cgplot, bug? [message #80972 is a reply to message #80971] |
Fri, 27 July 2012 05:17  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
David Fanning writes:
> But, the solution is simple. Don't use SYMCAT here!!!
> If you don't use it, then the symbol value is NOT
> hard-coded, but is evaluated at the time the
> cgPlot command is executed.
Well, the symbol value IS hard-coded, but the values
are hard-coded as 6 and 9, not as 8, as they were
in the original example.
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: cgwindow and cgplot, bug? [message #80974 is a reply to message #80972] |
Fri, 27 July 2012 05:13  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Mats Löfdahl writes:
> I just noticed a possible bug in cgwindow/cgplot. Here is a minimal example.
>
> The following lines make a plot with two data points represented as squares:
>
> cgwindow, /free
> cgplot,/add,[1,2],[2,1], psym=symcat(6),xrange=[0,5],yrange=[0,5]
>
> If I add the following line:
>
> cgplot,/add,/over,[1,2],[3,2], psym=symcat(9)
>
> I get two more points as circles as expected - AND the two points from the first cgplot call are ALSO turned into circles! I've updated the coyote library (five minutes ago) but the problem persists.
>
> In a cgdisplay window and without the /add keyword, the plot comes out as expected.
Yes, this is because keyword values are hard-coded when
they are added to the cgWindow. When you say PSYM=SymCat(6),
whatever SymCat(6) evaluates to is stored as the PSYM
keyword. In this case, (in almost *every* case!) that
value is 8. That happens to be the same value as
SymCat(9).
But, the solution is simple. Don't use SYMCAT here!!!
If you don't use it, then the symbol value is NOT
hard-coded, but is evaluated at the time the
cgPlot command is executed.
This problem is a result of writing the commands
incorrectly. The proper way to write these commands
is like this:
cgWindow
cgPlot, /add,[1,2],[2,1], psym=6, xrange=[0,5], yrange=[0,5]
cgplot, /add, /over, [1,2],[3,2], psym=9
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: cgwindow and cgplot, bug? [message #80975 is a reply to message #80974] |
Fri, 27 July 2012 03:40  |
Mats Löfdahl
Messages: 263 Registered: January 2012
|
Senior Member |
|
|
Den fredagen den 27:e juli 2012 kl. 12:18:58 UTC+2 skrev Mats Löfdahl:
> I just noticed a possible bug in cgwindow/cgplot. Here is a minimal example.
>
> The following lines make a plot with two data points represented as squares:
>
> cgwindow, /free
> cgplot,/add,[1,2],[2,1], psym=symcat(6),xrange=[0,5],yrange=[0,5]
>
> If I add the following line:
>
> cgplot,/add,/over,[1,2],[3,2], psym=symcat(9)
>
> I get two more points as circles as expected - AND the two points from the first cgplot call are ALSO turned into circles! I've updated the coyote library (five minutes ago) but the problem persists.
>
> In a cgdisplay window and without the /add keyword, the plot comes out as expected.
In case it matters: IDL Version 7.1.1 (linux x86_64 m64).
|
|
|