New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PGF backend: Fix vertical positioning of multi-line text #3003
Conversation
Thanks, I don't think the label appearing outside the figure is specific to the pgf backend with this patch though, I get the same thing with other backends. You can use |
@pwuertz Can you review this? |
@adamreeve Can you add an entry to CHANGELOG? |
Because text is drawn line-by-line, the anchor point of the text object being drawn is not applicable to all lines. When multi-line text is detected, apply the vertical alignment to the anchor manually using the requested x and y positions. This is based on the code in RendererSVG._draw_text_as_text.
Hi @tacaswell, I added the CHANGELOG entry and rebased to avoid a merge. |
Code looks very good to me, although I think it is the function calling the backend's |
Yeah, I had a quick look and An alternative approach could be to let the renderer say that it can handle multi-line text, then let it split the lines up itself and position them using the mtext info or just draw all the text with something like a parbox as you mentioned in #3000. |
Here is the quick fix that omits @adamreeve Thats right, it is probably much cleaner to move the |
Ok thanks, I'll close this PR then. Right, that makes sense, so providing correct mtext instances for the separate lines would be the most useful for the PGF backend. |
Thanks for your work and thoughts on this. |
This addresses issue #3000. The horizontal aligment is maintained, but for multi-line text the vertical alignment is applied manually in a similar way to the SVG backend.