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

Home » Public Forums » archive » output from cghistoplot draws outline correctly but the fill is shifted!?
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
output from cghistoplot draws outline correctly but the fill is shifted!? [message #90993] Thu, 21 May 2015 14:00 Go to next message
munka is currently offline  munka
Messages: 36
Registered: December 2009
Member
Hi y'all,

I'm using cghistoplot to make some histograms but a funny thing happens. One of my plots has the color filling shifted by one bin!

http://i.imgur.com/9IlvkQZ.png


The outline is in the correct spot but the fill isn't. If I switch to line_fill it seems to work

http://i.imgur.com/h6cWxFt.png

Even when I'm not plotting 3 plots the same data still causes this shift

Here is the bit where I plot the center plot...

cghistoPlot, 10^tbl.lsfr,ytitle='',xr=[0,180],$
yr=[0,100],xtitle='SFR' ,pos=midplotpos,ytickname=replicate(' ',10),xtickname=['','','','','','',' '],$
mininput=0.0,binsize=5.0,maxinput=180.0,DATACOLORNAME='black ',/noerase,$
thick=8,/outline,/FILLPOLYGON,polycolor='dodger blue',histdata=histdatas1,locations=locationss1,$
yminor=10

index=where(10^(sfrarr) gt 0.01 and 10^(sfrarr) lt 250)
cghistoPlot, 10^(sfrarr[index]),$
mininput=0.0,binsize=5.0,maxinput=180.0,/oplot,$
THICK=8,/fill,datacolorname='black',/outline,polycolor='red' ,$
line_thick=18,orientation=45


I'm not sure what is going wrong. I copy-pasted the code for each of the plots and only changed the plotting ranges and the data plotted. Does anyone have any clue as to whats going on here?



here is the whole code

http://pastebin.com/4zUA2dW7
Re: output from cghistoplot draws outline correctly but the fill is shifted!? [message #90994 is a reply to message #90993] Thu, 21 May 2015 14:15 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
mynameismunka@gmail.com writes:

> I'm not sure what is going wrong. I copy-pasted the code for each of the plots and only changed the plotting ranges and the data plotted. Does anyone have any clue as to whats going on here?

Are you using the very latest version of ctHistoPlot?

http://www.idlcoyote.com/programs/cghistoplot.pro

Here are the steps I take to solve problems with programs in the Coyote
Library:

http://idlcoyote.com/code_tips/fixcoyoteprogram.php

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
Re: output from cghistoplot draws outline correctly but the fill is shifted!? [message #90995 is a reply to message #90993] Thu, 21 May 2015 14:34 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
mynameismunka@gmail.com writes:

>
> Hi y'all,
>
> I'm using cghistoplot to make some histograms but a funny thing happens. One of my plots has the color filling shifted by one bin!
>
> http://i.imgur.com/9IlvkQZ.png
>
>
> The outline is in the correct spot but the fill isn't. If I switch to line_fill it seems to work
>
> http://i.imgur.com/h6cWxFt.png
>
> Even when I'm not plotting 3 plots the same data still causes this shift
>
> Here is the bit where I plot the center plot...
>
> cghistoPlot, 10^tbl.lsfr,ytitle='',xr=[0,180],$
> yr=[0,100],xtitle='SFR' ,pos=midplotpos,ytickname=replicate(' ',10),xtickname=['','','','','','',' '],$
> mininput=0.0,binsize=5.0,maxinput=180.0,DATACOLORNAME='black ',/noerase,$
> thick=8,/outline,/FILLPOLYGON,polycolor='dodger blue',histdata=histdatas1,locations=locationss1,$
> yminor=10

I would be curious to know at this spot in the code if the requested X
range is the same as the calculated X range. In other words:

Print, xrange
Print, !X.CRange

Are these the same when the following line is executed?

> index=where(10^(sfrarr) gt 0.01 and 10^(sfrarr) lt 250)
> cghistoPlot, 10^(sfrarr[index]),$
> mininput=0.0,binsize=5.0,maxinput=180.0,/oplot,$
> THICK=8,/fill,datacolorname='black',/outline,polycolor='red' ,$
> line_thick=18,orientation=45
>
>
> I'm not sure what is going wrong. I copy-pasted the code for each of the plots and only changed the plotting ranges and the data plotted. Does anyone have any clue as to whats going on here?

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
Re: output from cghistoplot draws outline correctly but the fill is shifted!? [message #90996 is a reply to message #90995] Thu, 21 May 2015 14:42 Go to previous messageGo to next message
munka is currently offline  munka
Messages: 36
Registered: December 2009
Member
On Thursday, May 21, 2015 at 2:34:50 PM UTC-7, David Fanning wrote:
> mynameismunka@gmail.com writes:
>
>>
>> Hi y'all,
>>
>> I'm using cghistoplot to make some histograms but a funny thing happens. One of my plots has the color filling shifted by one bin!
>>
>> http://i.imgur.com/9IlvkQZ.png
>>
>>
>> The outline is in the correct spot but the fill isn't. If I switch to line_fill it seems to work
>>
>> http://i.imgur.com/h6cWxFt.png
>>
>> Even when I'm not plotting 3 plots the same data still causes this shift
>>
>> Here is the bit where I plot the center plot...
>>
>> cghistoPlot, 10^tbl.lsfr,ytitle='',xr=[0,180],$
>> yr=[0,100],xtitle='SFR' ,pos=midplotpos,ytickname=replicate(' ',10),xtickname=['','','','','','',' '],$
>> mininput=0.0,binsize=5.0,maxinput=180.0,DATACOLORNAME='black ',/noerase,$
>> thick=8,/outline,/FILLPOLYGON,polycolor='dodger blue',histdata=histdatas1,locations=locationss1,$
>> yminor=10
>
> I would be curious to know at this spot in the code if the requested X
> range is the same as the calculated X range. In other words:
>
> Print, xrange
> Print, !X.CRange
>
> Are these the same when the following line is executed?
>
>> index=where(10^(sfrarr) gt 0.01 and 10^(sfrarr) lt 250)
>> cghistoPlot, 10^(sfrarr[index]),$
>> mininput=0.0,binsize=5.0,maxinput=180.0,/oplot,$
>> THICK=8,/fill,datacolorname='black',/outline,polycolor='red' ,$
>> line_thick=18,orientation=45
>>
>>
>> I'm not sure what is going wrong. I copy-pasted the code for each of the plots and only changed the plotting ranges and the data plotted. Does anyone have any clue as to whats going on here?
>
> Cheers,
>
> David
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
> Sepore ma de ni thue. ("Perhaps thou speakest truth.")

this should reproduce the bug http://pastebin.com/GpaPKqfT

adding

Print, !x.range
Print, !X.CRange

after both plot commands gives:

0.0000000 0.0000000
0.0000000 180.00000
0.0000000 0.0000000
0.0000000 180.00000

~Bill
Re: output from cghistoplot draws outline correctly but the fill is shifted!? [message #90997 is a reply to message #90996] Thu, 21 May 2015 14:43 Go to previous messageGo to next message
munka is currently offline  munka
Messages: 36
Registered: December 2009
Member
On Thursday, May 21, 2015 at 2:42:10 PM UTC-7, myname...@gmail.com wrote:
> On Thursday, May 21, 2015 at 2:34:50 PM UTC-7, David Fanning wrote:
>> mynameismunka@gmail.com writes:
>>
>>>
>>> Hi y'all,
>>>
>>> I'm using cghistoplot to make some histograms but a funny thing happens. One of my plots has the color filling shifted by one bin!
>>>
>>> http://i.imgur.com/9IlvkQZ.png
>>>
>>>
>>> The outline is in the correct spot but the fill isn't. If I switch to line_fill it seems to work
>>>
>>> http://i.imgur.com/h6cWxFt.png
>>>
>>> Even when I'm not plotting 3 plots the same data still causes this shift
>>>
>>> Here is the bit where I plot the center plot...
>>>
>>> cghistoPlot, 10^tbl.lsfr,ytitle='',xr=[0,180],$
>>> yr=[0,100],xtitle='SFR' ,pos=midplotpos,ytickname=replicate(' ',10),xtickname=['','','','','','',' '],$
>>> mininput=0.0,binsize=5.0,maxinput=180.0,DATACOLORNAME='black ',/noerase,$
>>> thick=8,/outline,/FILLPOLYGON,polycolor='dodger blue',histdata=histdatas1,locations=locationss1,$
>>> yminor=10
>>
>> I would be curious to know at this spot in the code if the requested X
>> range is the same as the calculated X range. In other words:
>>
>> Print, xrange
>> Print, !X.CRange
>>
>> Are these the same when the following line is executed?
>>
>>> index=where(10^(sfrarr) gt 0.01 and 10^(sfrarr) lt 250)
>>> cghistoPlot, 10^(sfrarr[index]),$
>>> mininput=0.0,binsize=5.0,maxinput=180.0,/oplot,$
>>> THICK=8,/fill,datacolorname='black',/outline,polycolor='red' ,$
>>> line_thick=18,orientation=45
>>>
>>>
>>> I'm not sure what is going wrong. I copy-pasted the code for each of the plots and only changed the plotting ranges and the data plotted. Does anyone have any clue as to whats going on here?
>>
>> Cheers,
>>
>> David
>> --
>> David Fanning, Ph.D.
>> Fanning Software Consulting, Inc.
>> Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
>> Sepore ma de ni thue. ("Perhaps thou speakest truth.")
>
> this should reproduce the bug http://pastebin.com/GpaPKqfT
>
> adding
>
> Print, !x.range
> Print, !X.CRange
>
> after both plot commands gives:
>
> 0.0000000 0.0000000
> 0.0000000 180.00000
> 0.0000000 0.0000000
> 0.0000000 180.00000
>
> ~Bill

Whoops. be sure to change the output path.
Re: output from cghistoplot draws outline correctly but the fill is shifted!? [message #90998 is a reply to message #90996] Thu, 21 May 2015 14:46 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
mynameismunka@gmail.com writes:

> adding
>
> Print, !x.range
> Print, !X.CRange
>
> after both plot commands gives:
>
> 0.0000000 0.0000000
> 0.0000000 180.00000
> 0.0000000 0.0000000
> 0.0000000 180.00000

Yeah, but not what I asked for. :-)

Print, xrange
Print, !X.CRange

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
Re: output from cghistoplot draws outline correctly but the fill is shifted!? [message #90999 is a reply to message #90997] Thu, 21 May 2015 14:47 Go to previous messageGo to next message
munka is currently offline  munka
Messages: 36
Registered: December 2009
Member
On Thursday, May 21, 2015 at 2:43:04 PM UTC-7, myname...@gmail.com wrote:
> On Thursday, May 21, 2015 at 2:42:10 PM UTC-7, myname...@gmail.com wrote:
>> On Thursday, May 21, 2015 at 2:34:50 PM UTC-7, David Fanning wrote:
>>> mynameismunka@gmail.com writes:
>>>
>>>>
>>>> Hi y'all,
>>>>
>>>> I'm using cghistoplot to make some histograms but a funny thing happens. One of my plots has the color filling shifted by one bin!
>>>>
>>>> http://i.imgur.com/9IlvkQZ.png
>>>>
>>>>
>>>> The outline is in the correct spot but the fill isn't. If I switch to line_fill it seems to work
>>>>
>>>> http://i.imgur.com/h6cWxFt.png
>>>>
>>>> Even when I'm not plotting 3 plots the same data still causes this shift
>>>>
>>>> Here is the bit where I plot the center plot...
>>>>
>>>> cghistoPlot, 10^tbl.lsfr,ytitle='',xr=[0,180],$
>>>> yr=[0,100],xtitle='SFR' ,pos=midplotpos,ytickname=replicate(' ',10),xtickname=['','','','','','',' '],$
>>>> mininput=0.0,binsize=5.0,maxinput=180.0,DATACOLORNAME='black ',/noerase,$
>>>> thick=8,/outline,/FILLPOLYGON,polycolor='dodger blue',histdata=histdatas1,locations=locationss1,$
>>>> yminor=10
>>>
>>> I would be curious to know at this spot in the code if the requested X
>>> range is the same as the calculated X range. In other words:
>>>
>>> Print, xrange
>>> Print, !X.CRange
>>>
>>> Are these the same when the following line is executed?
>>>
>>>> index=where(10^(sfrarr) gt 0.01 and 10^(sfrarr) lt 250)
>>>> cghistoPlot, 10^(sfrarr[index]),$
>>>> mininput=0.0,binsize=5.0,maxinput=180.0,/oplot,$
>>>> THICK=8,/fill,datacolorname='black',/outline,polycolor='red' ,$
>>>> line_thick=18,orientation=45
>>>>
>>>>
>>>> I'm not sure what is going wrong. I copy-pasted the code for each of the plots and only changed the plotting ranges and the data plotted. Does anyone have any clue as to whats going on here?
>>>
>>> Cheers,
>>>
>>> David
>>> --
>>> David Fanning, Ph.D.
>>> Fanning Software Consulting, Inc.
>>> Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
>>> Sepore ma de ni thue. ("Perhaps thou speakest truth.")
>>
>> this should reproduce the bug http://pastebin.com/GpaPKqfT
>>
>> adding
>>
>> Print, !x.range
>> Print, !X.CRange
>>
>> after both plot commands gives:
>>
>> 0.0000000 0.0000000
>> 0.0000000 180.00000
>> 0.0000000 0.0000000
>> 0.0000000 180.00000
>>
>> ~Bill
>
> Whoops. be sure to change the output path.

I made the arrays smaller and it still has the bug

http://pastebin.com/KUSFH0q0

here is the output

http://i.imgur.com/cTTDZ1P.png

~Bill
Re: output from cghistoplot draws outline correctly but the fill is shifted!? [message #91000 is a reply to message #90998] Thu, 21 May 2015 14:50 Go to previous messageGo to next message
munka is currently offline  munka
Messages: 36
Registered: December 2009
Member
On Thursday, May 21, 2015 at 2:46:36 PM UTC-7, David Fanning wrote:
> mynameismunka@gmail.com writes:
>
>> adding
>>
>> Print, !x.range
>> Print, !X.CRange
>>
>> after both plot commands gives:
>>
>> 0.0000000 0.0000000
>> 0.0000000 180.00000
>> 0.0000000 0.0000000
>> 0.0000000 180.00000
>
> Yeah, but not what I asked for. :-)
>
> Print, xrange
> Print, !X.CRange
>
> Cheers,
>
> David
>
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
> Sepore ma de ni thue. ("Perhaps thou speakest truth.")

% PRINT: Variable is undefined: XRANGE.
Re: output from cghistoplot draws outline correctly but the fill is shifted!? [message #91001 is a reply to message #91000] Thu, 21 May 2015 14:54 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
mynameismunka@gmail.com writes:

OK, what happens if you take the XRANGE keyword OFF of your first
cgHistoplot command?

David


--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
Re: output from cghistoplot draws outline correctly but the fill is shifted!? [message #91002 is a reply to message #91001] Thu, 21 May 2015 15:07 Go to previous messageGo to next message
munka is currently offline  munka
Messages: 36
Registered: December 2009
Member
On Thursday, May 21, 2015 at 2:54:20 PM UTC-7, David Fanning wrote:
> mynameismunka@gmail.com writes:
>
> OK, what happens if you take the XRANGE keyword OFF of your first
> cgHistoplot command?
>
> David
>
>
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
> Sepore ma de ni thue. ("Perhaps thou speakest truth.")

... it works! this fixes it. I played with it a bit and it seems like changing the lower bound causes it to mis-plot. Thanks for the help!

Its odd that the *outline* plots properly but the fill doesn't.
Re: output from cghistoplot draws outline correctly but the fill is shifted!? [message #91003 is a reply to message #91002] Thu, 21 May 2015 15:18 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
mynameismunka@gmail.com writes:

> ... it works! this fixes it. I played with it a bit and it seems like changing the lower bound causes it to mis-plot. Thanks for the help!
>
> Its odd that the *outline* plots properly but the fill doesn't.

Well, XRANGE is not keyword I expected anyone to use, so...

In the outline, I use the XRANGE I calculate for the plot. In the FILL,
I use the !X.CRANGE value for overplotting. They will be different, I
guess, if you use the unexpected XRANGE keyword via the always
troublesome keyword inheritance mechanism.

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
Re: output from cghistoplot draws outline correctly but the fill is shifted!? [message #91004 is a reply to message #91003] Thu, 21 May 2015 17:18 Go to previous messageGo to next message
munka is currently offline  munka
Messages: 36
Registered: December 2009
Member
On Thursday, May 21, 2015 at 3:18:35 PM UTC-7, David Fanning wrote:
> mynameismunka@gmail.com writes:
>
>> ... it works! this fixes it. I played with it a bit and it seems like changing the lower bound causes it to mis-plot. Thanks for the help!
>>
>> Its odd that the *outline* plots properly but the fill doesn't.
>
> Well, XRANGE is not keyword I expected anyone to use, so...
>
> In the outline, I use the XRANGE I calculate for the plot. In the FILL,
> I use the !X.CRANGE value for overplotting. They will be different, I
> guess, if you use the unexpected XRANGE keyword via the always
> troublesome keyword inheritance mechanism.
>
> Cheers,
>
> David
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
> Sepore ma de ni thue. ("Perhaps thou speakest truth.")


> troublesome keyword inheritance mechanism

Yep...

pro test1,in1,_EXTRA=es
plot,findgen(10),xrange=in1,_EXTRA=es,/xs
end

test1,[2,8],xrange=[1,5]



Q. What would the xrange of the plot be?

A. probably [0,9]


(just kidding, it ends up being [1,5] and throws no errors...)
Re: output from cghistoplot draws outline correctly but the fill is shifted!? [message #91005 is a reply to message #91004] Fri, 22 May 2015 05:19 Go to previous message
Yngvar Larsen is currently offline  Yngvar Larsen
Messages: 134
Registered: January 2010
Senior Member
On Friday, 22 May 2015 02:18:09 UTC+2, myname...@gmail.com wrote:
> On Thursday, May 21, 2015 at 3:18:35 PM UTC-7, David Fanning wrote:

>> troublesome keyword inheritance mechanism
>
> Yep...
>
> pro test1,in1,_EXTRA=es
> plot,findgen(10),xrange=in1,_EXTRA=es,/xs
> end
>
> test1,[2,8],xrange=[1,5]
>
>
>
> Q. What would the xrange of the plot be?
>
> A. probably [0,9]
>
>
> (just kidding, it ends up being [1,5] and throws no errors...)

You can always explicitly capture the keyword(s) that you want to manually calculate:

pro test1,in1,_EXTRA=es, XRANGE=_not_used_
plot,findgen(10),xrange=in1,_EXTRA=es,/xs
end

Not very pretty, but the advantages of _EXTRA outweigh the disadvantages most of the time, so I can live with it.

--
Yngvar
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: IDL Run-time error '-5'
Next Topic: 3D point cloud visualization

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

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

Total time taken to generate the page: 0.00557 seconds