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

Home » Public Forums » archive » Re: Histrogram plot in IDL using cgHistoplot
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Histrogram plot in IDL using cgHistoplot [message #76561] Wed, 15 June 2011 07:05 Go to previous message
Sasha Singh is currently offline  Sasha Singh
Messages: 13
Registered: November 2010
Junior Member
On Jun 14, 4:26 pm, Jeremy Bailin <astroco...@gmail.com> wrote:
> I would use value_locate to bin the data into your unequal bins, and then use judicious use of xticks, xtickv and xtickname to get the labels right. Something like this:
>
> ; Create some data that has the correct distribution. Presumably
> ; you don't need to do this since you already have your data!
> data = [randomu(seed,11)*3, 3+randomu(seed, 16)*3, 6+randomu(seed, 5)*4, $
>   10+randomu(seed,3)*10, 20+randomu(seed,4)*20, 40+randomu(seed,2)*20]
>
> ; Specify where the bin edges are
> bin_edges = [0,3,6,10,20,40,60]
> nbins = n_elements(bin_edges)-1
>
> ; Map your data onto the bins, so values between 0 and 3 become "0",
> ; values between 3 and 6 become "1", etc.
> data_bins = value_locate(bin_edges, data)
>
> ; Create an array with each bin edge duplicated for labelling
> labelnums = rebin(1 # bin_edges, 2, nbins+1, /sample)
> ; And create the label strings
> labels = string(labelnums[1:2*nbins], format='(%"%0d - %0d")')
>
> ; Finally create the histogram
> cghistoplot, data_bins, xrange=[0,nbins], xticks=nbins-1, $
>   xtickv=0.5+indgen(nbins), xtickname=labels
>
> -Jeremy.

Thank you. It works like a charm. The plot looks awesome :)

Sasha.
[Message index]
 
Read Message
Read Message
Previous Topic: New book: Modern IDL
Next Topic: Re: dynamic linking on Mac

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

Current Time: Wed Oct 08 18:05:07 PDT 2025

Total time taken to generate the page: 0.00408 seconds