[Thread Prev][Thread Next][Index]

Re: custom axis



On Tue, 15 Jun 2004, Matthieu JOUAN wrote:

> how can i define my own (Y in my case) axis
> with "variable" range, that means non regular.
> For example: 1-50, then 51-400, 401-2000, etc...

Hi Matthieu,
	I think the simplest way may be define three (or more)
viewports - one for each segment of the y-range.  Then do a plot in
each section using "ppl axset" to eliminate unwanted x-axes.
	The first step is in creating the viewports. I use a script
called "viewdef" to help design these and have included it at the end
of this message. In the case where there are three strips of equal
width, the three viewports are defined by

! vbot.jnl
ppl size 10 8 ; ppl axlen 8 2 ; ppl origin 1 1
def view/size=1/orig=0,0/clip=1,0.5 vbot

! vmid.jnl
ppl size 10 8 ; ppl axlen 8 2 ; ppl origin 1 1
def view/size=1/orig=0,0.25/clip=1,0.75 vmid

! vbot.jnl
ppl size 10 8 ; ppl axlen 8 2 ; ppl origin 1 1
def view/size=1/orig=0,0/clip=1,0.5 vbot

Make these three files then use the following demo where the function
v = i^3.3 which varies from 1 to 1995 for i=1,...,10 is plotted

! plotting a function in three strips, each with a linear y-range
region/i=1:10 ; let v=i^3.3
go vbot
plot/nolab/set v
ppl yaxis,0,50,10 ; ppl axlint,1,1 ; ppl yfor,(i2)
ppl axset,0,1,1,1 ; ppl plot ! bottom third has only a bottom x-axis
go vmid
ppl yaxis,50.1,400,50 ; ppl axlint,1,1 ; ppl yfor,(i3)
ppl axset,0,0,1,1 ; ppl plot ! middle third has no x-axes
go vtop
ppl yaxis,400.1,2000,400 ; ppl axlint,1,1 ; ppl yfor,(i4)
ppl axset,1,0,1,1 ; ppl plot ! top third has only a top x-axis
!----------------------------------------------------------------

The viewdef script below is something I wrote and have been using for
years. It is not the only way to define the viewports you need. Once
you have "chmod +x"-ed it and put it somewhere handy, the command
viewdef (or sp viewdef from within ferret) prints the cheat-sheet. I
used
	viewdef 10 8 8 2 1 1 1 1 vbot
	viewdef 10 8 8 2 1 3 1 1 vmid
	viewdef 10 8 8 2 1 5 1 1 vtop
to make the three viewports used in the demo.
Hope it helps,
Mick


#---------------------------------------------------------------
# viewdef - script to produce a ferret viewport definition with
#           the ferret lines needed written to "name".jnl
#
# usage: viewdef px py ax ay ox oy fx fy name
#                                  ___________________________
# where px = page width            |<----------px----------->| ^
#       py = page height           |     ....................| |
#       ax = x-axis length         |     .  ferret margin   .| |
#       ay = y-axis length         |     .   ____________   .| |
#       ox = x-component of origin |     <fx>|  plot    | ^ .| |
#       oy = y-component of origin |     .   | region   | ay.| py
#       fx = ferret margin in x    |(ox,oy)->!__________| v .| |
#       fy = ferret margin in y    |     .             ^    .| |
# all values in inches and         |     .             fy   .| |
#     name = name for viewport     |     ..............v.....| |
#                                  |       overall page      | |
# go name    will invoke viewport  |_________________________| v

# viewdef (or spawn viewdef in ferret) without arguments will
# display the usage and definition text above

#!/bin/csh -f

if ( $#argv < 9 ) then
   head -19 $home/bin/viewdef
else
   set jnl = $9:r.jnl

   echo $1 $2 $3 $4 $5 $6 $7 $8 $9  | awk '{           \
   origx = ($5-$7)/$1    ; origy = ($6-$8)/$2        ; \
   clipx = ($5+$3+$7)/$1 ; clipy = ($6+$4+$8)/$2     ; \
   str1  = "def view/size=1/orig=" ; str2 = "/clip=" ; \
   print "ppl size",$1,$2 ; print "ppl axlen",$3,$4  ; \
   print "ppl origin",$7,$8                          ; \
   print str1 origx","origy str2 clipx","clipy,$9    ; \
   print "set view",$9 }' >! $jnl
endif

# end of script


|!!! Mick.Spillane@noaa.gov !!!|
|__Room 2070 Bldg#3 NOAA/PMEL__|
|____Phone_:_(206)526-6780_____|




[Thread Prev][Thread Next][Index]

Dept of Commerce / NOAA / OAR / PMEL / TMAP

Contact Us | Privacy Policy | Disclaimer | Accessibility Statement