[Thread Prev][Thread Next][Index]

Re: [ferret_users] Ferret equivalent to Matlab "axis equal"



Here's a code snippet that defines the aspect for a window to plot a map with the correct ratio (taking into account the changing distance of a degree longitude). Call it with the 4 arguments for the west,east,south,north edges of your map.

You might want to edit horfrac, vertfrac, xstart, ystart, or make them arguments.

define symbol west `$1`;define symbol east `$2`;define symbol south `($3)`;define symbol north `($4)`
def sym emw `($east)-($west)`
def sym nms `($north)-($south)`
def sym avlat `(($north)+($south))/2`
def sym scale_emw `cos(pi*($avlat)/180)*($emw)`
def sym horfrac 1.3; def sym vertfrac 1.4 ! size of window relative to the plot box
let hor=`($scale_emw)*($horfrac)`; let vert=`($nms)*($vertfrac)`
set win/asp=`vert/hor`
def sym xstart `0.11`; def sym ystart `0.12` ! fractional distance to the left/bottom edge of the plot box def vi/axes/xli=($xstart),`($xstart)+1/($horfrac)`/ yli=($ystart),`($ystart)+1/($vertfrac)` glvi
set vi glvi

... now plot your map ...


On Jul 25, 2013, at 11:52 , Daiwei (David) Wang wrote:

Hi Ferreters,

I wonder if there is an easy way to "set the aspect ratio [of a viewport] so that the data units are the same in every direction" as with "axis equal" in Matlab [1]. In other words, for example, I'd like 1-degree-by-1-degree boxes shown as squares, not rectangles, in a shade plot.

Thanks,
David

[1] http://www.mathworks.com/help/matlab/ref/axis.html



[Thread Prev][Thread Next][Index]
Contact Us
Dept of Commerce / NOAA / OAR / PMEL / Ferret

Privacy Policy | Disclaimer | Accessibility Statement