[Thread Prev][Thread Next][Index]

[ferret_users] Contour Labels on White Box? Yes, it's possible but in an interactive way.



Hello All,

Many of us have probably used "polygon" to "white out" a portion of a plot, within Ferret, to make space for a label of some kind. A similar idea, but using mouse clicks to position such a white out box can be used to insert labels, such as contour labels, in an interactive but fairly painless manner. Attached is a script to do that and a demo graphic of the result. With the "boxlabel.jnl" script placed in your "ferret tools" directory, the commands that created that graphic are simply:

fill/i=1:80/j=1:60/nolab/lev=(0,160,20) i+j
repeat/k=20:140:20 (go boxlabel 0.1 `k` )
go boxlabel 0.2 "@p8Testing boxlabel.jnl"

The repeat loop calling "boxlabel" works for evenly spaced contours, but they could be entered one by one as was done in adding the caption.

NOTE: Mac users -- there is one function -- LABWID -- in the script that is not available in the version of Ferret I use on my Mac. It serves to make the width of the "white box" nice and tight and handle formatting characters like "@p2". A way around this would be to use the STRLEN function which is on the Mac but my suspicion is that the box would not be as tight -- and would not handle font/color (non-printing) characters like "@p2". Another option might be to add another argument "nchar" to the "go boxlabel" call and set "labwid" to nchar*labht instead.

Hope this helps. Some of the comments in the script may be useful; feel free to improve this first draft & suggestions are welcome.

Mick
PS The "where" function of Ferret is useful for interacting with the screen to extract coordinates (in user units) of features in a plot. I use it all the time to digitize for example or to define the corners of a subregion I want to zoom in on.

Sudheer Joseph wrote:
 I believe what Jammal meant is like the attached graph which is not
generated by ferret but using  gri ( , though I am not sure if it is
possible in ferret. It is a good feature if implemented particularly
when the labels get embedded in background colors
Sudheer


On Wed, Aug 5, 2009 at 10:34 PM, William S.
Kessler<william.s.kessler@xxxxxxxx> wrote:
I didn't understand the question (and still I'm not sure I understand it
even after Ansley's answer).

One solution to many of these dilemmas is to draw whatever you want using an
otherwise unused color, then do a simple edit of the resulting postscript
file to modify that particular color. Search the mail archives for "edit
postscript" and you should find instructions to change the colors by
modifying the "ct" (color table) code near the top of the postscript file.
It's pretty easy even if you know nothing about postscript code.

Another technique is to define two identical plot boxes (DEFINE VIEWPORT).
Make your background SHADE or FILL plot, then use the second viewport to
draw your white contours on top of that.

Billy K

On 5 Aug 09, at 9:14 AM, Ansley Manke wrote:

Hi Jammal,
No, there is not a way to make the labels for contour lines on a small
white background.  One idea for you to try is to use white for the lines and
labels, which might show up better, depending on the palettes you are using.

  yes? fill/i=1:15/j=1:15 i+j
  yes? contour/over/lev/color=white/i=1:15/j=1:15 i+j

Another thing people sometimes do is to make the final plot for a
publication, and then use a separate graphics editing program to make a few
changes to enhance the figure.  This might be another way to get exactly
what you want.

Ansley


jammal Tanclei wrote:
Dear Ferret users,

Is there any way to plot contour labels on white Box in CONTOUR command
not to be disturbed by FILLed or SHADed background?

Many thaks to you in advance.

J.

Love Cricket? Check out live scores, photos, video highlights and more.
Click here.



------------------------------------------------------------------------


PNG image

CAN MODE VERIFY

! boxlabel : Superimposes a white box on an existing plot, centered at a location
!            determined by a mouse click (the "where" command) and then writes a
!            text string in the whited-out box.
! Usage :
!      go boxlabel ht "mytext"
! where
!            ht     is the desired label height in inches
!            mytext is a string (which can include font and color choices @TR, @p2)
!                   The quotes are not needed if there is no whitespace so, for a
!                   contour label with height 0.1 inches and value 100 use
!                          go boxlabel 0.1 100
! NOTE:
! The value 1.6 in the definition of "laboxy" below is to include labels with
! "descenders" (like y or j). If there are none of these 1.4 would be better.
!
! Written 6-Aug-2009 by Mick.Spillane@xxxxxxxx

let labht=$1 ; let labstr="$2" ; let labwd=labwid(labstr,`labht`)
let xscal=(`($xaxis_max)` - `($xaxis_min)`)/`($ppl$xlen)`
let yscal=(`($yaxis_max)` - `($yaxis_min)`)/`($ppl$ylen)`

say "Use a mouse click to center the box"
where

let laboxx=labwd*{-0.5,0.5,0.5,-0.5}*xscal
let laboxy=1.6*labht*{-0.5,-0.5,0.5,0.5}*yscal
let labdy =`($ymouse)` - labht*yscal/2
poly/o/nolab/pal=white/co=x `($xmouse)`+laboxx,`($ymouse)`+laboxy
label `($xmouse)` `labdy` 0 0 `labht` @sr`labstr`

SET MODE/LAST VERIFY

[Thread Prev][Thread Next][Index]

Contact Us
Dept of Commerce / NOAA / OAR / PMEL / TMAP

Privacy Policy | Disclaimer | Accessibility Statement