Re: Centering multi-line text or titles

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Fri Jun 08 2012 - 09:21:25 MDT

Hi Carmen,

There's no easy way to center several lines of text using one title call.

You could use the special "~Hn~" function code to do horizontal moves
before each text string, and then you could calculate "n" based on
string lengths. This is kind of a pain.

There are two other things you can try. One is to do one centered title
and two right and left strings (see example streamline1.py at http://www.pyngl.ucar.edu/Examples/gallery.shtml)

Or, you can do the three centered titles. I've attached two scripts showing these two possibilities.

Both scripts use Ngl.text() to create the text string, and Ngl.add_annotation()
to attach it to the plot. You then use special resources
amOrthogonalPosF and amParallelPosF to move the string sideways or up/down.

I realize this is not clean. I'll add it to our list of enhancement requests to
maybe add another function code that behaves like "~C~" to give you
the carriage return, but that would also center the string.

--Mary

On Jun 8, 2012, at 8:29 AM, Carmen St. Jean wrote:

> Hello all,
>
> I cannot seem to get titles or text that contains carriage returns to
> be centered on my plots. If I keep my resources all the same and
> simply change the text to be a single line, then everything centers
> perfectly. I attached images of my resulting plots as examples.
>
> There do not seem to be any resources to get around this problem. I
> found one tutorial where a multi-line title was centered using spaces,
> which is an unrealistic solution in most cases.
>
> I am hoping to avoid adding and positioning each line of text
> separately. Is there a way to center multi-line strings that I have
> overlooked? If not, are there plans to fix this in future versions of
> PyNGL?
>
> Thanks,
>
> Carmen
> <lmofs_crosssection_a_temp_t0_multiline.png><lmofs_hires_crosssection_a_temp_t0_singleline.png>_______________________________________________
> pyngl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/pyngl-talk

_______________________________________________
pyngl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/pyngl-talk

Received on Fri Jun 8 09:21:31 2012

This archive was generated by hypermail 2.1.8 : Tue Jul 03 2012 - 15:43:36 MDT