You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
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.
Also have a look at the LaTeX issue mentioned on the legendflex docs, it is very much related.
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:
in MATLAB the extent of the text box is computed as some values [X, Y, width, height] in pixels (see the legendflex code), those explicit coordinates are translated by matlab2tikz to equivalent pgfplots code, but there we no longer have the guarantee that that extent is conveying the same semantic info (width should be large enough to contain the text, Y position and height are such that it aligns to the middle of the symbol) as in MATLAB; since we do not have that semantic info anymore when we convert the figure.
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: