Matlab 2015a inserts space before µ in long strings, but not in short ones (xlabel). In some cases one can work around by using UTF-8 letters, but this will fail in other situations (see ^2)
The font of the text should be Helvetica
but it looks different. Although get Fontname
returns Helvetica
.
This is a bug in MATLAB and already reported. I do not want to wait months until MATHWORKS fixes this bug.
How can I fix this bug my self? I tried to change the renderer to opengl
, but this mixes up all fonts even worse.
plot([2014 2015 2016], [0 1 0])
xlabel('MATLAB (\mu)')
ylabel('Space-bugs (\mum^2) (µm²) (µm^2)')
title('Number of wrong spaces in MATLAB')
textTT = text(2015-1, 1/2,'ugliest plot bugs ever', 'FontSize', 20, 'FontName', 'Helvetica');
text(2015, 1/3, get(textTT, 'Fontname')) % says Helvetica, but lies.
print -depsc2 -r864 -painters '/tmp/test.eps'
print -dpdf -r864 -painters '/tmp/test.pdf'
code rendered in Matlab 2015a on Linux 64 Bit
same code rendered in Matlab Windows 64 Bit by Luis Mendo:
EDIT 1: The bug is still present in 2015b and 2016a. The bug shows up in the Linux version, but not in the Windows version.
EDIT 2: Some suggested to use the internal latex interpreter. I think this is no solution, because it makes the code really hard to read if all fonts get replaced to slanted (or italic?) computer modern. There should be one font for the plot and units, title and labels must be written upright.
EDIT 3: The bug is still present in 2017b.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With