Multiline text/text wrap

Hi,

I’m new to PyGMT and GMT, but I haven’t found the answer by searching.

Is it possible to output multiline text/wrap text using a single text() command? I’ve tried putting a newline (\n) between words, as I would in matplotlib, but it’s ignored. There’s a ‘wrap’ option for text() but it doesn’t seem related.

Do I just need to manually add two text commands, one under the other? Or am I missing something obvious?

many thanks,

Emma

text does not honour \n. -B (titles, subtitles) will use <break> to make 2 separate lines. For all else see text -M for multiple lines and paragraphs.

Thanks, although those seem overkill for splitting a two-word annotation over 2 lines. Also, I have no idea how to apply them as PyGMT text() parameters!

I’ll try it manually, thanks for the suggestion though.

Remember we do all text in PostScript and are not computing distances from external fontmetrix. So splitting text over two “lines” is not just a carriage return/line feed operation. It affects other things like the box around text (if -W or -G) and other PostScript calculations. So not simple.

If it helps, @seisman had an example of using -M paragraph mode in PyGMT at https://github.com/GenericMappingTools/pygmt/issues/1078#issuecomment-802551364, but it involves creating a text file still.

Thank you, that’ll be very useful if I end up needing to wrap more than a couple of words.