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

Home » Public Forums » archive » Re: cgHistoplot issue
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: cgHistoplot issue [message #76065] Thu, 19 May 2011 07:47
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
David Fanning writes:

> Ah, of course! Thanks! Maybe I know
> how to fix this then. :-)

OK, I fixed cgHistogram. You can find it here:

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

In cgHistogram I was calculating the min and max
ranges for the plot in the variables xrange and yrange.
I was creating the plot scaffolding for the histogram
plot, by using the PLOT command like this:

Plot, xrange, yrange, ...

The fix was simply to create the plot like this:

Plot, [0,0], xrange=xrange, yrange=yrange, ...

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: cgHistoplot issue [message #76066 is a reply to message #76065] Thu, 19 May 2011 07:31 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Jeremy Bailin writes:

> I've actually run into this before. The algorithm that plot uses to decide on the y range is pretty straightforward - it uses the values of the data points within the x range that it is plotting. In David's example, there are *no* data points in the x range, so it defaults to [0,1]. Without looking into the internals of cghistoplot, I can't say for sure, but I would guess that a similar situation is occurring.

Ah, of course! Thanks! Maybe I know
how to fix this then. :-)

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: cgHistoplot issue [message #76067 is a reply to message #76066] Thu, 19 May 2011 07:28 Go to previous message
Jeremy Bailin is currently offline  Jeremy Bailin
Messages: 618
Registered: April 2008
Senior Member
I've actually run into this before. The algorithm that plot uses to decide on the y range is pretty straightforward - it uses the values of the data points within the x range that it is plotting. In David's example, there are *no* data points in the x range, so it defaults to [0,1]. Without looking into the internals of cghistoplot, I can't say for sure, but I would guess that a similar situation is occurring.

-Jeremy.
Re: cgHistoplot issue [message #76074 is a reply to message #76067] Wed, 18 May 2011 19:57 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Fabzou writes:

> I don't know if its a bug. Plot has always done what it *thinks* to be
> the best for the XY ranges. Sometimes it makes sense, sometimes not...

Well, it's true that it has a mind of its own about
aesthetic axes, but in 25 years I've never seen it
do something this perverse. I'm sure it's a bug, but
I have made no headway figuring out a theory
for how the bug came to exist. :-(

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: cgHistoplot issue [message #76076 is a reply to message #76074] Wed, 18 May 2011 19:25 Go to previous message
Fabzou is currently offline  Fabzou
Messages: 76
Registered: November 2010
Member
On 05/19/2011 12:48 AM, JBT wrote:
> Yeah, you are right, David. Then I guess this is a bug of plot rather than of cghistoplot. Anyway, it's not terribly a big deal, just annoying.
>
> JBT

I don't know if its a bug. Plot has always done what it *thinks* to be
the best for the XY ranges. Sometimes it makes sense, sometimes not...
Re: cgHistoplot issue [message #76077 is a reply to message #76076] Wed, 18 May 2011 15:50 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
David Fanning writes:

>
> JBT writes:
>
>> Just report one bug of cgHistoplot.
>>
>> When setting a xrange to cgHistoplot, it automatically changes the yrange too, which is not supposed to happen. You can repeat the problem with the following code.
>>
>> data = randomu(5L, 200)*20.
>> cgHistoplot, data, BINSIZE=1.0
>> cgHistoplot, data, BINSIZE=1.0, xr = [0, 15]
>>
>> The first two lines were actually copied from idlcoyote.com. And you can see the problem after running the third line.
>
> Humm. This turns out to be a property of the PLOT
> command that, frankly, I don't understand right
> at the moment. Consider this:
>
> IDL> x = [-0.96062616, 21.975719]
> IDL> y = [0,14.7]
> IDL> plot, x, y
>
> But, now set the XRANGE:
>
> IDL> plot, x, y, xrange=[0,15]
>
> What do you make of that!? :-(

If I try to zoom the plot:

IDL> fsc_zplot, x, y, xrange=[0,15]

It starts out broken, but as soon as I touch the plot
to zoom it, it does the right thing! Weird.

I don't know what to tell you. This looks like a bug with
the plot command to me.

This is one time when, I admit, iPlot produces a better
plot than the Plot command! :-)

IDL> iPlot, x, y, xrange=[0,15]

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: cgHistoplot issue [message #76078 is a reply to message #76077] Wed, 18 May 2011 15:48 Go to previous message
Jianbao is currently offline  Jianbao
Messages: 16
Registered: December 2008
Junior Member
Yeah, you are right, David. Then I guess this is a bug of plot rather than of cghistoplot. Anyway, it's not terribly a big deal, just annoying.

JBT
Re: cgHistoplot issue [message #76079 is a reply to message #76078] Wed, 18 May 2011 15:28 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
JBT writes:

> Just report one bug of cgHistoplot.
>
> When setting a xrange to cgHistoplot, it automatically changes the yrange too, which is not supposed to happen. You can repeat the problem with the following code.
>
> data = randomu(5L, 200)*20.
> cgHistoplot, data, BINSIZE=1.0
> cgHistoplot, data, BINSIZE=1.0, xr = [0, 15]
>
> The first two lines were actually copied from idlcoyote.com. And you can see the problem after running the third line.

Humm. This turns out to be a property of the PLOT
command that, frankly, I don't understand right
at the moment. Consider this:

IDL> x = [-0.96062616, 21.975719]
IDL> y = [0,14.7]
IDL> plot, x, y

But, now set the XRANGE:

IDL> plot, x, y, xrange=[0,15]

What do you make of that!? :-(

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: IDL 7.1 to 8.1, workspace migration
Next Topic: Re: log scale colorbar in IDL 8.0

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

Current Time: Wed Oct 08 13:36:33 PDT 2025

Total time taken to generate the page: 0.00625 seconds