display histogram

Charles Seman Charles.Seman at NOAA.GOV
Wed Feb 9 16:42:25 EST 2005


Dear Viviane,

Please see http://grads.iges.org/grads/gadoc/gradcomdsetxaxis.html
which contains:
------------------------------------------------------------------------------------------------


    set xaxis

set xaxis start end <increment>

Specifies where the labeled tick marks will be placed on the X-axis.
Labeled tick marks begin at the specified start value and end at the
specified end value with the specified increment. Labeled tick marks may
have no relation to data or dimensions.


      Usage Notes

   1. Reset by clear
      <http://grads.iges.org/grads/gadoc/gradcomdclear.html>, but not
      display <http://grads.iges.org/grads/gadoc/gradcomddisplay.html>.
   2. See also set yaxis
      <http://grads.iges.org/grads/gadoc/gradcomdsetyaxis.html>.

------------------------------------------------------------------------------------------------
also please see http://grads.iges.org/grads/gadoc/gradcomdsetxlabs.html
which contains:


    set xlabs

set xlabs lab1 | lab2 | ...

label the x axis with lab1, lab2, lab3,...

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

You could also try an interactive approach... Here is some code which
prompts the user for labels and the location to plot them.  The "y"
location from the first "bpos" click is used for subsequent "x"
locations so all of the labels are on a straight horizontal line...

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

say ' '
say '---------------------------------------------------------'
say ' '
say 'Plotting Numerical Bin Labels'
say ' '
say '---------------------------------------------------------'
say ' '
say 'Enter number of bin labels desired'
pull nbin
if (nbin<=0)
 say 'Number of bin labels desired is 'nbin
 say 'Is this correct?  Yes or No'
 pull answer
 if(answer=No | answer=no | answer=N | answer=n)
  say 'Enter number of bin labels desired'
  pull nbin
 endif
endif
if (nbin>10)
 say 'Number of bin labels desired is 'nbin
 say 'Is this correct?  Yes or No'
 pull answer
 if(answer=No | answer=no | answer=N | answer=n)
  say 'Enter number of bin labels desired'
  pull nbin
 endif
endif
if (nbin>0)
 say 'Enter bin label #1:'
 pull args
 say 'Click where you want the label'
 'query bpos'
 x = subwrd(result,3)
 y = subwrd(result,4)
 'draw string 'x' 'y' 'args
  nb=2
 while (nb<=nbin)
  say 'Enter bin label #'nb':'
  pull args
  say 'Click where you want the label'
  'query bpos'
  x = subwrd(result,3)
  'draw string 'x' 'y' 'args
  nb=nb+1
 endwhile
endif
------------------------------------------------------------------------------------------------

Another approach would be to use coordinate transformations.  The
following is from
http://grads.iges.org/grads/gadoc/script.html#storing

q <http://grads.iges.org/grads/gadoc/gradcomdquery.html> transform
coord1 coord2 -- Coordinate transformations

      where transform is one of:
      xy2w       XY coords to world coords
      xy2gr      XY coords to grid coords
      w2xy       world coords to XY coords
      w2gr       world coords to grid coords
      gr2w       grid coords to world coords
      gr2xy      grid coords to XY coords

XY coords are inches on the page (screen) where the page is 11x8.5
inches or 8.5x11 inches, depending on how GrADS was started.

World coords are lat, lon, lev, time or val, depending on what the
dimension environment is when the grid was displayed. Note that time is
displayed (and must be specified) in GrADS absolute date/time format.
val is the value coordinate for a 1-D plot (linegraph).

Grid coordinates are the i,j indices the grid being displayed. For
station data sets, grid and world coordinates are equivalent except for
the time dimension. Note that if you display a grid from a 'wrapped'
data set, the grid numbers may be out of range of the actual file grid
numbers. (A 'wrapped' data set is a data set that covers the earth in
the longitude direction. Wrapping takes place automatically). The
conversions are done consistently, but you may want to be sure you can
handle the wrapping case if your data set is global.

N.B. Coordinate transform queries are only valid after something has
been displayed, and the transformations apply only to the most recent
item that has been displayed.
------------------------------------------------------------------------------------------------

I think you could use "w2xy" or "gr2xy" to get the (x,y) plot location
for a label, given a dataset parameter as described above, then draw a
string at that (x,y) location... I don't have any code that does this...


I hope this helps,
Chuck





Viviane Silva wrote:

>Hi,
>
>I created a histogram in which the interval are -0.5
>to 0.5, 0.5 to 1.5, etc. What should I do to make
>grads display the x label on the right position? i,e.
>have the label,for example, zero below the bar which
>correspond to the interval -0.5 to 0.5.
>
>I appreciate your help.
>
>Thanks,
>
>Viviane Silva
>
>
>
>__________________________________
>Do you Yahoo!?
>Yahoo! Mail - Find what you need with new enhanced search.
>http://info.mail.yahoo.com/mail_250
>
>

--

********************************************************************
 Charles Seman                                Charles.Seman at noaa.gov
 Geophysical Fluid Dynamics Laboratory / NOAA
 Princeton University                          voice: (609) 452-6547
 P.O. Box 308                                    fax: (609) 987-5063
 Princeton, NJ  08542-0308            http://www.gfdl.noaa.gov/~cjs/
********************************************************************

"The contents of this message are mine personally and do not reflect
any position of the Government or NOAA."

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20050209/7c0ffd9a/attachment.html 


More information about the gradsusr mailing list