Re: Shaded circles request. [message #7906] |
Mon, 27 January 1997 00:00 |
davidf
Messages: 2866 Registered: September 1996
|
Senior Member |
|
|
David Kennedy <D.Kennedy@qub.ac.uk> writes:
> Hi, apologies in advance for an almost 'do my work' question, but
> I'm a bit stumped as to where to start with something.
>
> I wish to draw a plot with North-South and East-West axes upon which is
> drawn an incomplete grid of points. For each point I wish to have
> a circle drawn which is filled with a colour indicating the strength
> of the data point.
> Problems with this:
> (1) I want to label the axes with a minimum of fuss, so I'd like to
> preserve their values (not 0->array size) from the start.
> (2) How can I draw filled circles?
> (3) How can I get the filled cirles to automatically scale according to their
> value?
Hi David. I can't write this code for you (that is, unless you want
to *pay* me! :-), but here is a function named circle that will get
you started. Be sure your plot has a square aspect ratio or your
circles will be ellipses. (I use the program ASPECT, which you
can download from my web page.)
Here is how I would use it:
; Load yellow circle color and set up plot.
TVLCT, 255, 255, 0, 1
PLOT, Findgen(100), Position=ASPECT(1.0), /NoData
; Draw some circles. Radius and circle center in DATA coordinates.
POLYFILL, CIRCLE(20, 40, 5), /FILL, COLOR=1
POLYFILL, CIRCLE(40, 20, 10), /FILL, COLOR=1
POLYFILL, CIRCLE(70, 30, 15), /FILL, COLOR=1
POLYFILL, CIRCLE(20, 80, 12), /FILL, COLOR=1
This might give you some ideas.
David
***********************************************
FUNCTION CIRCLE, xcenter, ycenter, radius
step = (radius/24.0)
x = FLTARR(25)
y = FLTARR(25)
; Construct a circle
FOR j=0,24 DO BEGIN
x(j) = j*step
y(j) = SQRT(radius^2 - x(j)^2)
ENDFOR
x = [x, Reverse(x)]
y = [y, -Reverse(y)]
x = [-Reverse(x), x]
y = [y,y]
; Center the circle at the specified coordinates.
x = x + xcenter
y = y + ycenter
points = FLTARR(2, 100)
points(0,*) = x
points(1,*) = y
RETURN, points
END
*************************************************
-----------------------------------------------------------
David Fanning, Ph.D.
Fanning Software Consulting
2642 Bradbury Court, Fort Collins, CO 80521
Phone: 970-221-0438 Fax: 970-221-4762
E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com
-----------------------------------------------------------
|
|
|