Re: Centering multi-line text or titles

From: Carmen St. Jean <carmen.stjean_at_nyahnyahspammersnyahnyah>
Date: Fri Jun 08 2012 - 13:43:56 MDT

Hello Mary,

I appreciate the fast response with the example code. Your
annotations solution (plot3.py) looks pretty good. With minor
adjustments, I was able to add it to my code and also make it work for
the bottom text too. Thank you so much!

It'd be great if there was a newline character that didn't change the
justification. Thanks also for adding it to the enhancement wishlist!

Have a nice weekend,

Carmen

On Fri, Jun 8, 2012 at 11:21 AM, Mary Haley <haley@ucar.edu> wrote:
> 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
>
>
Received on Fri Jun 8 13:44:04 2012

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