On Monday, October 7, 2013 8:58:18 PM UTC+5:30, suicida...@gmail.com wrote:
> On Monday, October 7, 2013 9:12:13 AM UTC-6, Krishnakumar M.A wrote:
>
>> Hi all,
>
>>
>
>>
>
>>
>
>> I'm having a bit trouble here while using usersym. What I want to make is circles with the third column of the file (which means that the circles will have different radii). But, I have no idea if one can use the usersym like the way in which I have used. the code and the error message is given below. Please let me know the problem with the script.
>
>>
>
>>
>
>>
>
>> Thanks.
>
>>
>
>>
>
>>
>
>> data=fltarr(3,100)
>
>>
>
>> readf,1,data
>
>>
>
>> l=data(0,*)
>
>>
>
>> b=data(1,*)
>
>>
>
>> r=data(2,*)
>
>>
>
>>
>
>>
>
>> for i=0,99 do begin
>
>>
>
>> n=17.0
>
>>
>
>> theta=findgen(n)/(n-1.0)*360.0
>
>>
>
>> x(i)=l(i)+r(i)*sin(theta)/1.0
>
>>
>
>> y(i)=b(i)+r(i)*cos(theta)/1.0
>
>>
>
>> usersym,x(i),y(i)
>
>>
>
>>
>
>>
>
>> plot,l(i),b(i),psym=8
>
>>
>
>> endfor
>
>>
>
>>
>
>>
>
>> The returned error was
>
>>
>
>>
>
>>
>
>> % Compiled module: $MAIN$.
>
>>
>
>> % USERSYM: Expression must be an array in this context: <FLOAT (
>
>>
>
>> -1.99965)>.
>
>>
>
>> % Execution halted at: $MAIN$ 16
>
>
>
> I'm not sure why you want/need to use usersym in the first place. You've already calculated the x and y locations, so just plot them directly.
>
>
>
> Also - sin/cos work on radians, not degrees, and you have your sin and cos backwards in regards to x and y, and I'm not sure why you're dividing them by 1. Also, x and y are not preallocated, so you can't start subscripting them as if they're existing arrays, and even if they were preallocated, it would break because you're trying to store an entire 17 element array into a single element.
>
>
>
> You'll also want to reform your l, b, and r arrays so they're N elements rather than 1xN elements. The latter can cause some funky issues later on.
>
>
>
> Keep in mind that by using plot inside the for loop, you're going to end up with 100 separate plots, one point on each. I doubt this is what you truly want, so you probably want to make the plot outside of the loop, and then oplot inside.
>
>
>
> data=fltarr(3,100)
>
> readf,1,data
>
> l=reform(data[0,*])
>
> b=reform(data[1,*])
>
> r=reform(data[2,*])
>
>
>
> plot, [0,1], [0,1], /nodata, xrange=?, yrange=?
>
> for i=0,99 do begin
>
> n=17.0
>
> theta=findgen(n)/(n-1.0)*2*!pi
>
> x=l(i)+r(i)*cos(theta)
>
> y=b(i)+r(i)*sin(theta)
>
>
>
> oplot,x,y
>
> endfor
Thanks a lot. That was a great help for me.
As I said, I never used usersym in IDL, since I always use some other language to do plotting. But as I came to know that it will be easier in IDL, I tried my hand.
Thanks for the help.
|