Open helicities opened 7 years ago
Thank you for reporting this bug. The truncation is indeed not the right thing to do with log-scaled axes.
Code-wise, I think this boils down to adding 2 options to formatDim
to indicate whether the environment we're in is log-scaled and in that case don't apply truncation.
Any updates on this? I'm encountering the same error here. Thanks.
https://github.com/matlab2tikz/matlab2tikz/blob/62a038d9833d4d48581acb630da550e40799338f/src/matlab2tikz.m#L6708 could be changed to a different truncation instead of 3 decimal places for log plots. I'll try to make a PR tomorrow.
It seems this is not yet fixed. Why not use str = sprintf('%.3e', value);
to keep the three significant digits? Also rounding with the tolerance, as is done here
https://github.com/matlab2tikz/matlab2tikz/blob/62a038d9833d4d48581acb630da550e40799338f/src/matlab2tikz.m#L6700
results in problems since round(1E-8 / 1E-7)*1E-7 = 0
.
The coordinates of annotations (like text) are incorrectly truncated in log-log plots. Let's consider the following example with two annotations A and B:
The produced tikz-code (only for the text part) reads:
where the y-coordinate of A has been set to 0 (instead of 1e-6), while the coordinate of B was interpreted correctly (1e-2). This results of course in a wrong placement of the annotation in the final figure. The rounding to zero should only be performed in lin-lin plots but not in loglog plots.