Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

multiline plot title

18 views
Skip to first unread message

Ryan Jones

unread,
Apr 14, 2014, 12:49:53 PM4/14/14
to metsci-...@googlegroups.com
Is it possible to have a plots title have more than one line?

Ryan

Geoffrey Ulman

unread,
Apr 14, 2014, 1:34:51 PM4/14/14
to metsci-...@googlegroups.com

Ideally, you should simply be able to say: Plot2D.setTitle( "Line 1\nLine 2\nLine 3" )

However, Plot2D currently uses a SimpleTextPainter under the hood to paint the title, and that particular GlimpsePainter doesn't support multi-line text.

I've added an issue so that it gets fixed as time allows: https://github.com/metsci/glimpse/issues/43

That said, SimpleTextPainter can paint text aligned vertically to the Top, Center, or Bottom of a GlimpseLayout area. So if you don't need more than three lines, you can just add three of your own SimpleTextPainters to the GlimpseLayout defining the plot title area.

Here's a runnable example: https://gist.github.com/ulmangt/10666984

Once you do this, if you want to change the color, font, etc... of the text, you'll have to call the setter methods on the painters you created. The title methods on the Plot2D won't do anything since it thinks the title is empty.

As a side note, as long as you can get at the GlimpseLayout defining the space you want to draw in, you can always add GlimpsePainter subclasses to perform any arbitrary OpenGL rendering you want in that space. So if you want to put something different than the simple text title that Plot2D provides, that's always an option (although might involve a good bit more work/customization).

Ryan Jones

unread,
Apr 14, 2014, 3:54:06 PM4/14/14
to metsci-...@googlegroups.com
Thanks, I tried the escape sequence and quickly realized that wasn't implmented. All I needed was three lies so your example worked perfectly.
Reply all
Reply to author
Forward
0 new messages