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

Home » Public Forums » archive » Re: Q: square plots in IDL
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: Q: square plots in IDL [message #3246] Mon, 28 November 1994 09:57
sjt is currently offline  sjt
Messages: 72
Registered: November 1993
Member
Giuseppe Vacanti (gvacanti@estsa2.estec.esa.nl) wrote:

: Hello-

: I would like to plot data so that the aspect ratio of the plot is
: equal to 1 (a circle would actually be a circle on paper, and not
: an ellipse, as it is in my IDL documentation). I have played with
: various key-words but I don't seem able to get it right.

: Any input is welcome.
: Thanks,

An initial point:
Unless you have made a square page with the WINDOW procedure or a
DEVICE call (depending on your device) avoid using procedures which set
up data coordinates implicitly (e.g. PLOT, SURFACE etc.).

Instead you will need to create your own plot transform.

1) Determine size of device each way in cm
xcm = !d.x_size/float(!d.x_px_cm)
ycm = !d.y_size/float(!d.y_px_cm)

2) Determine your scaling factor (user unit/cm)(assume xr, yr are the ranges
of x and y that you need).

xscl = xr/xcm
yscl = yr/ycm
scl = xscl > yscl

3) Define your plot transform (assume xm, ym are the minimum x and y you
want to plot)

!x.s = [-xm, 1.]/(scl*xcm)
!y.s = [-ym, 1.]/(scl*ycm)

This seemed to work when I tested it to plot a unit circle in an 800x437
pixel window using PLOTS

: --

: Giuseppe Vacanti
: Astrophysics Division / SERCO
: ESTEC - European Space Agency
: P.O. Box 299 Internet: Giuseppe.Vacanti@astro.estec.esa.nl
: 2200 AG, Noordwijk Phone : +31-71-654175
: The Netherlands FAX : +31-71-654690

--
+------------------------+---------------------------------- --+---------+
| James Tappin, | School of Physics & Space Research | O__ |
| sjt@star.sr.bham.ac.uk | University of Birmingham | -- \/` |
| "If all else fails--read the instructions!" | |
+----------------------------------------------------------- --+---------+
Re: Q: square plots in IDL [message #3249 is a reply to message #3246] Mon, 28 November 1994 06:46 Go to previous message
bowman is currently offline  bowman
Messages: 121
Registered: September 1991
Senior Member
In article <3bc67s$6em@info.estec.esa.nl>, gvacanti@estsa2.estec.esa.nl
(Giuseppe Vacanti) wrote:

> Hello-
>
> I would like to plot data so that the aspect ratio of the plot is
> equal to 1 (a circle would actually be a circle on paper, and not
> an ellipse, as it is in my IDL documentation). I have played with
> various key-words but I don't seem able to get it right.
>
> Any input is welcome.
> Thanks,

This works for me:

PRO SET_ASPECT, aspect, MARGIN = margin

; This program sets the plot position, !P.POSITION
; to ensure the desired aspect ratio for the final
; plot with a margin on each side.

;Find the aspect ratio of the current window
daspect = FLOAT(!D.Y_SIZE)/FLOAT(!D.X_SIZE)
IF NOT KEYWORD_SET(margin) THEN margin = 0.05

IF(aspect LE daspect) THEN BEGIN
x0 = margin
y0 = 0.50 - (0.5 - margin)*(aspect/daspect)
x1 = 1.0 - margin
y1 = 0.50 + (0.5 - margin)*(aspect/daspect)
ENDIF ELSE BEGIN
x0 = 0.50 - (0.5 - margin)*(daspect/aspect)
y0 = margin
x1 = 0.50 + (0.5 - margin)*(daspect/aspect)
y1 = 1.0 - margin
ENDELSE
!P.POSITION = [x0, y0, x1, y1]

RETURN
END


Call it with aspect = 1.0. You can vary the margin as you wish.

Ken Bowman

P.S. As always, bug reports welcome.

--
Dr. Kenneth P. Bowman 409-862-4060
Associate Professor 409-862-4132 fax
Climate System Research Program bowman@csrp.tamu.edu
Department of Meteorology PP-Glider
Texas A&M University
College Station, TX 77843-3150
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: thanks
Next Topic: Call_external under Solaris

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

Current Time: Wed Oct 08 15:15:44 PDT 2025

Total time taken to generate the page: 0.00564 seconds