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

Home » Public Forums » archive » Re: labeling my polarplot
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: labeling my polarplot [message #34225] Fri, 28 February 2003 09:15 Go to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Helena (hschlueter@ifm.uni-kiel.de) writes:

> i want to label my polarplot in polarcoordinates. i tried it with
> xyouts but its not working. the plot is a circle with a radiationfield
> inside, thats with polar_contour. around of the field is the circle
> with plot. the circle should be labelled with tickmarks (45, 90, 135,
> 180,...360 degree). can anybody help me with that? thanks for
> responding.

Oh, dear. Well, IDL is not going to give you a lot
of help here. One of the problems (as I discovered
this morning) is that the ISOTROPIC keyword on the
CONTOUR (or POLAR_CONTOUR) command doesn't exactly
give you an isotropic plot. :-(

It's *almost* isotropic. But it is just damn hard
to fit a circle around the plot. (An ellipse works.) :-)

Anyway, in the code below, I had to resort to my ASPECT
program to calculate the correct position for the
plot in the window. It was the only way I could fit
a circle around it.

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

And there is only one program in the world worth having
to draw a circle, and that is TVCIRCLE from the NASA
Goddard Astronomy Library:

http://idlastro.gsfc.nasa.gov/homepage.html

That said, here is some code that will produce a filled
polar contour plot, with circular annotations.

;*********************************************************** *******
PRO Example

; Number of contour levels

nlevels = 12

; Load program colors.

LoadCT, 0
LoadCT, 13, NColors=nlevels, Bottom=1
annotation = nlevels + 2
background = nlevels + 3
foreground = nlevels + 4
TVLCT, 70, 70, 70, annotation
TVLCT, 255, 255, 224, background
TVLCT, 0, 0, 0, foreground
contourcolors = Indgen(nlevels)+1

; Create data values to be contoured.

nr = 12 ; number of radii
nt = 18 ; number of Thetas
r = FINDGEN(nr)/(nr-1)
theta = 2*!PI * FINDGEN(nt)/(nt-1)
z = COS(theta*3) # (r-0.5)^2
z = z * 1000.0

; Create contour levels.

step = (Max(z) - Min(z)) / nlevels
levels = Min(z) + Indgen(nlevels) * step

; Create the polar contour plot:

IF (!D.Flags AND 256) NE 0 THEN BEGIN
Device, Decomposed=0
Window, XSize=500, YSize=500
ENDIF
POLAR_CONTOUR, z, theta, r, /CELL_FILL, $
c_color=contourcolors, Levels=levels, $
Position=Aspect(1.0), $
;ISOTROPIC=1, $ ; This doesn't work :-(
XStyle=4, YStyle=4, $
BACKGROUND=background, $
Color=foreground
POLAR_CONTOUR, z, theta, r, Levels=levels, /OVERPLOT, $
C_Label=Replicate(1, nlevels), Color=foreground

; Draw a circle.

TVCircle, 1.0, 0, 0, /Data, Color=annotation, Thick=2

; Draw tick marks on the circle.

FOR j=0, 315, 45 DO BEGIN
degrees = j * !DtoR
PLOTS, [0.95*cos(degrees), 1.05*cos(degrees)], $
[0.95*sin(degrees), 1.05*sin(degrees)], $
Color=annotation, Thick=2
ENDFOR

; Label the plot.

XYOutS, 1.1, -0.03, '0', Charsize = 1.25, $
Color=annotation, Alignment=0.0, CharThick=2
XYOutS, 0.8, 0.77, '45', Charsize = 1.25, $
Color=annotation, Alignment=0.0, CharThick=2, Orientation=45
XYOutS, 0.0, 1.1, '90', Charsize = 1.25, $
Color=annotation, Alignment=0.5, CharThick=2
XYOutS, -0.8, 0.77, '135', Charsize = 1.25, $
Color=annotation, Alignment=1.0, CharThick=2, Orientation=-45
XYOutS, -1.1, -0.03, '180', Charsize = 1.25, $
Color=annotation, Alignment=1.0, CharThick=2
XYOutS, -0.8, -0.83, '225', Charsize = 1.25, $
Color=annotation, Alignment=1.0, CharThick=2, Orientation=45
XYOutS, 0.0, -1.2, '270', Charsize = 1.25, $
Color=annotation, Alignment=0.5, CharThick=2
XYOutS, 0.8, -0.83, '315', Charsize = 1.25, $
Color=annotation, Alignment=0.0, CharThick=2, Orientation=-45

END
;*********************************************************** *******

Notice that everything uses data coordinates. If you
use DEVICE coordinates (as you were trying to do in
your original code) you will have a devil of a time getting
the code to work both on your display and in PostScript
output.

This code will work in whatever device you care to
draw it in.

Cheers,

David
--
David W. Fanning, Ph.D.
Fanning Software Consulting, Inc.
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
Re: labeling my polarplot [message #34304 is a reply to message #34225] Fri, 28 February 2003 16:03 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
David Fanning (david@dfanning.com) writes:

> That said, here is some code that will produce a filled
> polar contour plot, with circular annotations.

Did I mention that I was unemployed (in case anybody,
like, needs some work done or something). Anyway,
I fixed this code up to be a little more general
and I wrote an article about the process, including
a little picture that shows why ISOTROPIC doesn't
work.

Cheers,

David

--
David W. Fanning, Ph.D.
Fanning Software Consulting, Inc.
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: no backwards compatibility in IDL 5.6
Next Topic: writing ascii files (with really long lines...)

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

Current Time: Wed Oct 08 15:49:55 PDT 2025

Total time taken to generate the page: 0.00530 seconds