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

Home » Public Forums » archive » Re: Draw a Histogram Plot
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: Draw a Histogram Plot [message #56900] Wed, 21 November 2007 14:39
Vince Hradil is currently offline  Vince Hradil
Messages: 574
Registered: December 1999
Senior Member
On Nov 21, 12:39 pm, JD Smith <jdsm...@as.arizona.edu> wrote:
> On Tue, 20 Nov 2007 13:46:01 -0700, David Fanning wrote:
>> Folks,
>
>> I've ticked another item off my life-time TO-DO list by writing a program
>> to give me a decent histogram plot when I want one.
>
>> I'm already thinking about version 1.2, but I thought I would get some
>> feedback before I spent too much more time on it.
>
>> You can learn about it and see how it works here:
>
>> http://www.dfanning.com/graphics_tips/histoplot.html
>
> Looks very nice, and I haven't tried it, but I'd call this a "bar plot"
> more than a histogram plot. If it would be possible to avoid all the
> vertical bar lines, it would be more useful to me. So essentially it
> would look like PSYM=10, but bins would go in the correct place, and have
> neatly finished ends. I usually kludge it by shifting a half bin, and
> adding endpoints on the X axis.
>
> JD

Just change the lines:
FOR j=0L, N_Elements(bins)-1 DO BEGIN
PlotS, [bins[j], bins[j]], min_value > [!Y.CRange[0],
histDataToPlot[j]] < max_value, $
Color=dataColor
ENDFOR

to only do j=0 and j=n_elements(bins)-1.
Re: Draw a Histogram Plot [message #56903 is a reply to message #56900] Wed, 21 November 2007 11:10 Go to previous message
Trae is currently offline  Trae
Messages: 23
Registered: May 2007
Junior Member
I bought an online copy of your book, just so that I could give you
money. Great little programs like this make me think what a good
investment that was.

Thanks! I'll be using this often.


Cheers
-Trae


On Nov 20, 1:46 pm, David Fanning <n...@dfanning.com> wrote:
> Folks,
>
> I've ticked another item off my life-time TO-DO list by
> writing a program to give me a decent histogram plot when
> I want one.
>
> I'm already thinking about version 1.2, but I thought I
> would get some feedback before I spent too much more time
> on it.
>
> You can learn about it and see how it works here:
>
> http://www.dfanning.com/graphics_tips/histoplot.html
>
> Cheers,
>
> David
Re: Draw a Histogram Plot [message #56904 is a reply to message #56903] Wed, 21 November 2007 10:39 Go to previous message
JD Smith is currently offline  JD Smith
Messages: 850
Registered: December 1999
Senior Member
On Tue, 20 Nov 2007 13:46:01 -0700, David Fanning wrote:

> Folks,
>
> I've ticked another item off my life-time TO-DO list by writing a program
> to give me a decent histogram plot when I want one.
>
> I'm already thinking about version 1.2, but I thought I would get some
> feedback before I spent too much more time on it.
>
> You can learn about it and see how it works here:
>
> http://www.dfanning.com/graphics_tips/histoplot.html


Looks very nice, and I haven't tried it, but I'd call this a "bar plot"
more than a histogram plot. If it would be possible to avoid all the
vertical bar lines, it would be more useful to me. So essentially it
would look like PSYM=10, but bins would go in the correct place, and have
neatly finished ends. I usually kludge it by shifting a half bin, and
adding endpoints on the X axis.

JD
Re: Draw a Histogram Plot [message #56905 is a reply to message #56904] Wed, 21 November 2007 10:41 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Ed Hyer writes:

> This is a valuable thing. Like many people I'm sure, I had a kluge I
> had been using for this, but I look forward to shifting to something
> more robust.
>
> The rotating fill values and line-fill options are great!
>
> I haven't actually put it through its paces, but looking through the
> code I see this:
>
> ; Calculate the histogram.
> histdata = Histogram(dataToHistogram, Binsize=binsize,
> Max=Max(dataToHistogram),
> Min=Min(dataToHistogram), _EXTRA=extra)
>
> For generating a good histogram, you need to be able to specify the
> MIN (and sometimes the MAX) values to HISTOGRAM(). Right now, if you
> feed a MIN value into HISTOPLOT, it will choke because there is
> already a MIN_VALUE keyword.

Yes, access to the HISTOGRAM command is bothering me, too.
I was hoping to finesse it, since simple access was all I
required for my application, but I realized I probably
wouldn't be able to get away with this for long.

We really need multiple _EXTRA keywords, or targeted keywords,
or something. There are three different COMMANDS I want access
to in this program, and having to resort to one _EXTRA is
giving me heartburn. :-(

I some ideas, but I'm working on getting a failed hard drive
back in business this morning....

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Re: Draw a Histogram Plot [message #56906 is a reply to message #56904] Wed, 21 November 2007 10:30 Go to previous message
MarioIncandenza is currently offline  MarioIncandenza
Messages: 231
Registered: February 2005
Senior Member
David,

This is a valuable thing. Like many people I'm sure, I had a kluge I
had been using for this, but I look forward to shifting to something
more robust.

The rotating fill values and line-fill options are great!

I haven't actually put it through its paces, but looking through the
code I see this:

; Calculate the histogram.
histdata = Histogram(dataToHistogram, Binsize=binsize,
Max=Max(dataToHistogram),
Min=Min(dataToHistogram), _EXTRA=extra)

For generating a good histogram, you need to be able to specify the
MIN (and sometimes the MAX) values to HISTOGRAM(). Right now, if you
feed a MIN value into HISTOPLOT, it will choke because there is
already a MIN_VALUE keyword.

My "feature request" would be a means to have both PLOT min/max and
HIST min/max.

The application is, for example, a floating-point dataset where I need
an indication of how many zero values. So, for example, if my data
have three significant digits after the decimal, and a range of 0-100,
then I want:

h=histogram(data,min=-9.999,bin=10)
hist_plot,h,x_range=[0,100],/xstyle

--Edward H.
Re: Draw a Histogram Plot [message #56907 is a reply to message #56906] Wed, 21 November 2007 09:44 Go to previous message
R.G.Stockwell is currently offline  R.G.Stockwell
Messages: 163
Registered: October 2004
Senior Member
"Brian Larsen" <balarsen@gmail.com> wrote in message
news:e1292802-6a1a-4e93-a74b-86fcdf63c4f0@o6g2000hsd.googleg roups.com...
> This whole thing makes me wonder... what would be involved in
> implementing a print_fanning_version() routine to print the versions
> of your routines? One could then check that again a list on the
> website?

even more usefull would be a 'find redundant files' routine
in your path.

...hold on a sec....

Cheers,
bob
Re: Draw a Histogram Plot [message #56908 is a reply to message #56907] Wed, 21 November 2007 08:54 Go to previous message
Brian Larsen is currently offline  Brian Larsen
Messages: 270
Registered: June 2006
Senior Member
This whole thing makes me wonder... what would be involved in
implementing a print_fanning_version() routine to print the versions
of your routines? One could then check that again a list on the
website?

This could be useful for analysis code I distribute to colleague as
well... interesting

One thought is that there is a procedure that knows the name of all
the routines in question, it calls them with a version flag that
returns a version number that is then printed... but they may be
another or better way.


Cheers,

Brian





------------------------------------------------------------ --------------
Brian Larsen
Boston University
Center for Space Physics
Re: Draw a Histogram Plot [message #56909 is a reply to message #56908] Wed, 21 November 2007 08:48 Go to previous message
Brian Larsen is currently offline  Brian Larsen
Messages: 270
Registered: June 2006
Senior Member
> You could possibly have a problem with a VERY old version
> of FSC_COLOR with more than one call. I doubt it very much
> with a more recent version:

Yep, I have a fanning directory with all of your routines in it but in
my larsen directory (ahead in !path) was an ancient version of
fsc_color() from before I got organized and that was the issue. I
removed the old version and It works like a champ now!!!

Thanks for the help,

Brian

------------------------------------------------------------ --------------
Brian Larsen
Boston University
Center for Space Physics
Re: Draw a Histogram Plot [message #56910 is a reply to message #56909] Wed, 21 November 2007 08:43 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Brian Larsen writes:

> I have had issues with more than one call to fsc_color in a routine
> before with legend, maybe its related?

You could possibly have a problem with a VERY old version
of FSC_COLOR with more than one call. I doubt it very much
with a more recent version:

http://www.dfanning.com/programs/fsc_color.pro

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Re: Draw a Histogram Plot [message #56911 is a reply to message #56910] Wed, 21 November 2007 08:41 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Ben writes:

> Here's my device info... { ppc darwin unix Mac OS X 6.3 Mar 23
> 2006 32 64}, so it is might be aversion thing. Note that
> Brian's "Translation table" is enabled and mine is bypassed.

There could be something to this. I ran into something like
this the other day with a Mac user. Something in her startup
file was setting this BYPASS_TRANSLATION keyword to the DEVICE
command, and she was getting strange colors in COLORBAR.

I suspect the line in her STARTUP file was put there
to work around a previous Mac color problem. I don't recall
now what value it is suppose to be set to. If you have
something like that, though, Brian, I'd try removing it
or setting it to the opposite value.

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Re: Draw a Histogram Plot [message #56914 is a reply to message #56911] Wed, 21 November 2007 08:38 Go to previous message
Brian Larsen is currently offline  Brian Larsen
Messages: 270
Registered: June 2006
Senior Member
>
> Brian, can you step through the code and see what is
> going on? I expect it draws the first PLOT command
> correctly (since you get a white background). But I
> would be MOST curious to know what happens then.
> Please be sure you have the latest version, too.

Stepped through (after making sure I had the latest) and didn't learn
too much...
after this section (lines 208-213):
Plot, binsToPlot, histdataToPlot, $ ; The fudged
histogram and bin data.
Background=backcolor, $ ; The background
color of the display.
NoData=1, $ ; Draw the axes
only. No data.
XStyle=5, $ ; Exact axis
scaling. No autoscaled axes.
YRange=yrange, $ ; The Y data
range.
YStyle=5, $ ; Exact axis
scaling. No autoscaled axes.
_Extra=extra, $ ; Pass any extra
PLOT keywords.
XTICKFORMAT='(A1)', YTICKFORMAT='(A1)'
the plot window popped up blank white, and didn't change from that at
any step.

But I did learn something else...
I think this is certainly an issue with fsc_color.

IDL> plot, findgen(10)
; gives a plot white on black
IDL> plot, findgen(10), color=fsc_color('red')
; gives a plot, red on black
IDL> plot, findgen(10), color=fsc_color('red'),
background=fsc_color('white')
; gives a blank white window

I have had issues with more than one call to fsc_color in a routine
before with legend, maybe its related?


Brian

------------------------------------------------------------ --------------
Brian Larsen
Boston University
Center for Space Physics
Re: Draw a Histogram Plot [message #56916 is a reply to message #56914] Wed, 21 November 2007 08:24 Go to previous message
ben.bighair is currently offline  ben.bighair
Messages: 221
Registered: April 2007
Senior Member
On Nov 21, 11:12 am, David Fanning <da...@dfanning.com> wrote:
> Brian Larsen writes:
>> here is that output. It feels to me like a white on white plot
>> issue...
>
>> MacBook pro, IDL 6.4.1, Leopard
>
> Oh, Macintosh!!! I knew it. :-(
>
> It sounds like a white on white thing to me, too.
> This is what FSC_COLOR would do if it couldn't find
> the color you specified. It defaults to white. But,
> with no error messages.... And a Macintosh....
> Quien sabe?
>
> Let's just say it wouldn't be the first time I've had
> to add work-arounds for Macs in my code. :-)
>
> Anyone else having trouble on a Mac?

Hi,

Works right out of the box for me. This is a great routine!

Here's my device info... { ppc darwin unix Mac OS X 6.3 Mar 23
2006 32 64}, so it is might be aversion thing. Note that
Brian's "Translation table" is enabled and mine is bypassed.

IDL> help, /device
Available Graphics Devices: CGM HP LJ NULL PCL PRINTER PS REGIS TEK X
Z
Current graphics device: X
Server: X11.0, The XFree86 Project, Inc, Release 40400000
Display Depth, Size: 24 bits, (1024,768)
Visual Class: TrueColor (4)
Bits Per RGB: 8 (8/8/8)
Physical Color Map Entries (Emulated / Actual): 256 / 256
Colormap: Shared, 16777216 colors. Translation table: Bypassed
Graphics pixels: Decomposed, Dither Method: Ordered
Write Mask: 16777215 (decimal) ffffff (hex)
Graphics Function: 3 (copy)
Current Font: <default>, Current TrueType Font: <default>
Default Backing Store: Pixmap.
Window Status: ---------------------
id typ( x, y, backing store) id typ( x, y,
backing store)
0: Win( 512, 373, Pixmap)

Thanks for the great tool!
Ben
Re: Draw a Histogram Plot [message #56917 is a reply to message #56916] Wed, 21 November 2007 08:12 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Brian Larsen writes:

> here is that output. It feels to me like a white on white plot
> issue...
>
> MacBook pro, IDL 6.4.1, Leopard

Oh, Macintosh!!! I knew it. :-(

It sounds like a white on white thing to me, too.
This is what FSC_COLOR would do if it couldn't find
the color you specified. It defaults to white. But,
with no error messages.... And a Macintosh....
Quien sabe?

Let's just say it wouldn't be the first time I've had
to add work-arounds for Macs in my code. :-)

Anyone else having trouble on a Mac?

Brian, can you step through the code and see what is
going on? I expect it draws the first PLOT command
correctly (since you get a white background). But I
would be MOST curious to know what happens then.
Please be sure you have the latest version, too.

http://www.dfanning.com/programs/histoplot.pro

Thanks,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Re: Draw a Histogram Plot [message #56918 is a reply to message #56917] Wed, 21 November 2007 07:20 Go to previous message
Brian Larsen is currently offline  Brian Larsen
Messages: 270
Registered: June 2006
Senior Member
Maybe another piece of the puzzle.

IDL> histoplot, randomu(seed, 1000), /line_fill
% Compiled module: HISTOPLOT.
% Compiled module: FSC_COLOR.
works and shows a red on white plot





Cheers,

Brian

------------------------------------------------------------ --------------
Brian Larsen
Boston University
Center for Space Physics
Re: Draw a Histogram Plot [message #56919 is a reply to message #56918] Wed, 21 November 2007 06:57 Go to previous message
Brian Larsen is currently offline  Brian Larsen
Messages: 270
Registered: June 2006
Senior Member
David,

here is that output. It feels to me like a white on white plot
issue...

MacBook pro, IDL 6.4.1, Leopard

IDL> help, /device
Available Graphics Devices: CGM HP LJ NULL PCL PRINTER PS REGIS TEK X
Z
Current graphics device: X
Server: X11.0, The X.Org Foundation, Release 70200000
Display Depth, Size: 24 bits, (1680,1028)
Visual Class: TrueColor (4)
Bits Per RGB: 8 (8/8/8)
Physical Color Map Entries (Emulated / Actual): 256 / 256
Colormap: Private, 16777216 colors. Translation table: Enabled
Graphics pixels: Combined, Dither Method: Ordered
Write Mask: 16777215 (decimal) ffffff (hex)
Graphics Function: 3 (copy)
Current Font: <default>, Current TrueType Font: <default>
Default Backing Store: Pixmap.
IDL> histoplot, randomu(seed, 1000)
% Compiled module: HISTOPLOT.
% Compiled module: FSC_COLOR.


Cheers,

Brian

------------------------------------------------------------ --------------
Brian Larsen
Boston University
Center for Space Physics
Re: Draw a Histogram Plot [message #56920 is a reply to message #56919] Wed, 21 November 2007 00:34 Go to previous message
Werner is currently offline  Werner
Messages: 3
Registered: August 2005
Junior Member
On 20 Nov., 21:46, David Fanning <n...@dfanning.com> wrote:
> Folks,
>
> I've ticked another item off my life-time TO-DO list by
> writing a program to give me a decent histogram plot when
> I want one.
>
> I'm already thinking about version 1.2, but I thought I
> would get some feedback before I spent too much more time
> on it.
>
> You can learn about it and see how it works here:
>
> http://www.dfanning.com/graphics_tips/histoplot.html
>
> 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.")

David,

works fine for me!

Thanks a lot for another great contribution!!!

Cheers,
Werner
Re: Draw a Histogram Plot [message #56925 is a reply to message #56920] Tue, 20 November 2007 15:05 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Brian Larsen writes:

> What setting do I have or not have to make this work?

Humm. Just don't know. Passes all the tests here.
Code looks solid.

What kind of machine? What version of IDL? What
color decomposition state when you run the program?
(Shouldn't matter, of course.)

Can I see a HELP, /DEVICE and then the call to the
program.

Thanks,

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.")
Re: Draw a Histogram Plot [message #56926 is a reply to message #56925] Tue, 20 November 2007 14:50 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Brian Larsen writes:

> Again we all thank you much for all the fantastic programs and help,
> however on this one maybe I have an odd setting or something...
>
> when I run histoplot, randomn(seed, 1000) I get a blank white
> screen... not too good for a default behavior. When I specify colors
> it works like a champ.
>
> What setting do I have or not have to make this work?

Well, that's weird. :-)

No error messages about not finding FSC_COLOR or
something like that?

Don't know. Too weird.

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.")
Re: Draw a Histogram Plot [message #56928 is a reply to message #56926] Tue, 20 November 2007 14:24 Go to previous message
Brian Larsen is currently offline  Brian Larsen
Messages: 270
Registered: June 2006
Senior Member
David,

> I've ticked another item off my life-time TO-DO list by
> writing a program to give me a decent histogram plot when
> I want one.

Again we all thank you much for all the fantastic programs and help,
however on this one maybe I have an odd setting or something...

when I run histoplot, randomn(seed, 1000) I get a blank white
screen... not too good for a default behavior. When I specify colors
it works like a champ.

What setting do I have or not have to make this work?


Cheers,

Brian

------------------------------------------------------------ --------------
Brian Larsen
Boston University
Center for Space Physics
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: compile all obsolete routines at once
Next Topic: 3D Scatterplot with iMap/iImage

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

Current Time: Wed Oct 08 15:09:45 PDT 2025

Total time taken to generate the page: 0.00890 seconds