Re: more questions

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Thu, 4 Nov 2004 16:32:13 -0700 (MST)

> Hello everyone,
> I also have some questions regarding plotting with PyNGL:
> 1. I make lots of similar plots/maps that use the same settings for
> several resources. Is there a way to specify a "resource file" with
> the common resource settings that can be used in several different
> Python scripts?

Hi Ivan,

Yes, you can use a resource file called ".hluresfile" that you put in
your home directory. Note that you cannot set the "ngl" resources in
this file.

So, for example, if you always want a white background, black
foreground, helvetica font, a function code of "~" (the default is a
colon, which is a common character in titles), and a size of 700x700
whenever you send your output to an X11 window, you would create a
file called "~/.hluresfile", and put the following six lines in it:

*wkForegroundColor : (/0.,0.,0./)
*wkBackgroundColor : (/1.,1.,1./)
*Font : helvetica
*txFuncCode : ~
*wkWidth : 700
*wkHeight : 700

There is more information about resource files in the PyNGL document:

> 2. Is there a way to change the view port size (vpWidthF or
> vpHeightF) but keep the X and Y axis labels the same size?

Whenever you change the width and height of your plot, other aspects
of the plot (including the X/Y axis labels) will scale accordingly.
To fix the size of these labels, you need to set them explicitly:

resources.tiXAxisFontHeightF = 0.025
resources.tiYAxisFontHeightF = 0.025

If you want to retrieve the font heights from your current plot so you
know what to set them to before you change the size, add the following
lines after your plot is created:

contour = Ngl.contour(wks,data,resources)
ysize = Ngl.get_float(contour.base,"tiYAxisFontHeightF")
xsize = Ngl.get_float(contour.base,"tiXAxisFontHeightF")
print xsize, ysize

Then, use the values for xsize and ysize to set your font heights.

> 3. How do I make the labelbar legends that are smaller than one to
> be in the format "0.1" instead of ".1"?

For some of our text resources, like the tickmark labels, we have a
corresponding "Format" resource that allows you to format the strings
used. However, I don't see a similar resource for labelbar
labels. I'm not sure if this is an oversight, or if it just hasn't
been implemented. [Dave B, can you pipe in here?]

For a work-around, you can set the labels yourself:

resources.cnExplicitLabelBarLabelsOn = True
resources.lbLabelStrings = ["0.1","0.2","0.3",...,]

> 4. Is it possible to use Ngl.panel to (for example) put one XY plot
> and 3 filled contour maps in one frame and specify a single
> labelbar for the filled contour maps? When I tried to do that I
> got errors saying that the panel contained plots (the XY plot) that
> were not consistent with a labelbar attribute.

Ngl.panel should only be used for plots that are the same size. If you
want to panel different sized plots, the best thing to do is control
the locations and sizes yourself using the vpXF, vpYF, vpWidthF, and
vpHeightF resources.

The "" example script shows how to create different plots
and put them on the same page. I believe you need the latest PyNGL
version in order to run it. Try:

   pyngl meteogram

and it should copy a file called "" in your current working
directory, run it through Python, and create a PostScript file
called "".

> I would also like to thank Mary Haley and Fred Clare for their
> effort and for giving us the ability to do high quality graphics
> under Python.
> - Ivan

Flattery will get you everywhere! Thanks for the compliment. It
really has been the effort of the whole NCL team to bring you these
high-quality graphics.


> --
> Ivan Lima
> Woods Hole Oceanographic Institution, MC&G MS #25
> 360 Woods Hole Road, Woods Hole, MA 02543-1543 USA
> _______________________________________________
> pyngl-talk mailing list

Mary Haley         
NCAR/SCD/VETS                303-497-1254 (voice)
1850 Table Mesa Dr           303-497-1804 (fax)
Boulder, CO  80305
pyngl-talk mailing list
Received on Thu Nov 04 2004 - 16:32:57 MST

This archive was generated by hypermail 2.2.0 : Thu Jan 19 2006 - 21:30:17 MST