On Oct 16, 10:04 am, leon.w...@gmail.com wrote:
> On 15 sep, 20:26, kishore1...@gmail.com wrote:
>
>
>
>> On Sep 11, 3:01 pm, plim.dream...@gmail.com wrote:
>
>>> Greetings all!
>>> It has been a while since I last posted here, for me that's a good
>>> sign.
>
>>> Contour plots have always been full of issues. Contour plots and
>>> "histogram"... It's like the user wants to do one thing and the
>>> program wants to do another...
>
>>> I have a set of irregularly distributed sources. 2 dimensional space.
>>> x, y.
>>> I would like to plot a contour of their density distribution. So I
>>> figured, i'll use hist_2d to grid the space into bins of 0.1 by 0.1
>>> and then contour plot the result.
>
>>> result =
>>> hist_2d(hmk,jmh,bin1=0.1,bin2=0.1,max1=max(hmk),max2=max(jmh ),
>>> min1=min(hmk), min2=min(jmh))
>
>>> levels = 30
>>> step=(max(result)-min(result))/levels
>>> userlevels=indgen(levels)*step + min(result)
>>> contour,result,levels=userlevels,background=1,color=black,xs tyle=1,ystyle=1
>
>>> Right?! Anybody see any major error thus far?
>>> The thing is that the contour plot comes out with its axis ranging
>>> from 0 to 50 whereas the input data only ranges from -1 to 4. And I
>>> can't figure out why.
>
>>> Any help is greatly appreciated,
>>> Plim
>
>> Hi
>> In your contour program you missed some params.
>> For example
>> contour,Z(dim1,dim2),x(dim1),y(dim2),levels=lvls,position=po s1,xrange=[limit1,limit2],thick=3,xsty=1,ysty=1,charsize=0.9 ,/
>> follow
>
>> just follow above method.
>
>> Kishore
>
> Hi !
>
> What do you mean with dim1 and dim2?
>
> I have two vectors both with 9125 elements. After hist_2d, I get
> an array of [24,15].
>
> When I'm triying to plot the contours of the array mentioned above
> the axis are ranging in different scales. Could you help me?
>
> thanks and have a nice day!
You need the x and y coordinates of "result". If you create result
using:
result = hist_2d(data, min1=min1,max1=max1,bin1=bin1,
min2=min2,max2=max2,bin2=bin2)
then(*) you end up with result being nx by ny, where
nx = (max1-min1)/bin1
ny = (max2-min2)/bin2
with coordinate values
xcoords = min1 + bin1*lindgen(nx)
ycoords = min2 + bin2*lindgen(ny)
In this case, xcoords and ycoords are what you want to feed into
contour.
(*)However, watch out for floating point arithmetic issues that may
give you one bin more than you think you should have. nx and ny are
really ceil() of the expressions I gave.
-Jeremy.
|