-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
[Bug]: leading whitespace in legend and labels ignored with usetex=True #24166
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
Comments
This is likely due to |
My guess is that we need to somehow hook the new-paragraph ( |
Is there a update on this? I have a similar problem with adding leading whitespace to the tick labels. |
@zweihuehner For ticklabels I think you can right-align the text and get the effect I suspect you want. I do not think this is a regression (it has always been like this) and is unfortunately not a high priority issue. For this to move forward we need someone to look into the latex -> dvi pipeline and sort out how to extract the intended bounding box (including white space). |
A workaround. I also had a similar issue for axis label. I solved it by moving the whole label.
I guess it is more difficult to do it for legend texts, but maybe it is still possible? |
Bug summary
As raised in a question on stackoverflow, none of the typical latex commands for horizontal white space (e.g.
~
,\,
,\quad
,\hphantom{whitespace}
) seem to work at the start of a text label when usingtext.usetex=True
.The commands work as expected in the middle of a text label.
Code for reproduction
Actual outcome
As you can see in the image below, none of the horizontal white space commands seem to be doing anything as long as they are at the head of the legend label or xlabel.
They all work fine when starting with some other character. Compare legend labels 4, 5, and 6.
\hphantom{whitespace}
doesn't do anything in label 4, but in label 5 after a leading dot it correctly produces exactly the amount of white space that matches the horizontal space of the wordwhitespace
as shown in label 6.Expected outcome
The latex commands
~
,\,
,\quad
,\hphantom{whitespace}
should produce horizontal white space even when at the start of a text label.System
module://matplotlib_inline.backend_inline
The text was updated successfully, but these errors were encountered: