I have found that under some circumstances MATLAB will print negative -0.0 as an axis tick. How can I eliminate this?
Problem code
y = linspace(-.4,.3,100);
plot(y)
ax = gca();
ax.YAxis.TickLabelFormat = '%.1f'`
This code produces a plot like this where instead of zero tick reading '0.0' it reads '-0.0'.
I think the key here is that the interval between the maximum and minimum of the Y axis cannot be represented exactly as a float, so the 'zero' tick is actually located at -5.6e-17. You can see this if instead use the formatting ax.YAxis.TickLabelFormat = '%.1e'
For picky formatting reason, I really prefer that all my axis ticks have the same number of digits (i.e. -0.1, 0.0, 0.1 rather than -0.1, 0, 0.1). Is there any way to eliminate the negative zero in this formatting?
Using MATLAB2017a on MacOS Sierra 10.12.4