-
Notifications
You must be signed in to change notification settings - Fork 318
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
Text from legendflex has vertical position offset #1118
Comments
I agree with you that it's inconvenient to use. However, I would disagree with your evaluation of where the error is: it is not in matlab2tikz, but rather in legendflex. A quick read of it's source code indicates that legendflex is looking at the extent of the text boxes to size the secondary legend. Intuitively: on the MATLAB rendering it is looking at the text, checking: this textbox is 50 px wide, so the whole box should be e.g. 60 px wide (50px + padding) such that the box is bigger than the text. However, on the matlab2tikz and LaTeX side, we only see a text box containing some text and a rectangle that is 60 px wide. Matlab2tikz has no more semantic information that the box should be bigger than a certain string of text, so it just translates that into the equivalent pgfplots code taking into account whatever information it has on hand. So unfortunately, there is nothing immediate that can be done in matlab2tikz to mitigate this; as the issue seems to stem from how the extents of those objects get set in legendflex. So I would suggest to use the workarounds mentioned on the legendflex documation. |
Woops, I didn't fully read your post that it's mainly about the vertical alignment. However, the source is the same: |
Thanks for the explanation. I will then use my workaround and the tips from the legendflex docu you mentioned. |
I am currently trying to save a figure with multiple legends created by legendflex. There is a minimal example in my fork of the repository.
With matlab2tikz the vertical position of the legend text has an offset which disturbs the figure and in other cases makes the text leave the box.
If I manually add -6 to the text vertical position, then the position looks ok:
In Matlab and in PDF export, the spacing looks ok:
Therefore, the error should be in the way which matlab2tikz handles the text.
The cutting of the text to the right can be solved by the padding command in legendflex, but also is annoying.
The text was updated successfully, but these errors were encountered: