[matlab2tikz] YTick changes when removing YTickLabel
Show older comments
Hello,
I use boxplot to produce different graphs. I arrange those graphs next to each other in LaTex. I set YLim for all equal. It looks like this:

Everything is fine, except that I want to save space and therefore want to delete YTickLabel without any other changes. Then the YTicks change as well! It looks like this:

I tried to avoid the change of YTick on YTickLabel remove adding the following lines, which read out YTick before removing YTickLabel and set it again after removing YTickLabel. But it did not work! Why? Is there any possibility to make YTick NOT CHANGE when removing YTickLabel?

Thanks in advance for your help!!
using Matlab R2015a on Windows
____________________
Solution: matlab2tikz added a line ytick={....} to the code which modified axes. Adding uncomment to this line in the output file via script solved the problem in a work-around.
____________________
Kind regards Tobias
6 Comments
dpb
on 5 Apr 2016
Give us a pasted text demo code (short as possible) that illustrates the issue that can paste in and use instead of images; nothing anybody can do with them other than look.
It would seem simply clearing 'yticklabel' shouldn't affect any of the tick positions themselves, agreed. I don't have time at the moment to try to duplicate as have meeting in few minutes so help us help you by giving the example in code...
Mike Garrity
on 6 Apr 2016
Actually it can affect the tick positions.
We're just guessing without seeing the code, but the tickpicker chooses tick values based on the amount of room it has, and the length of the tick labels affects the amount of room it has. This means that the interaction between the two can be surprising and non-linear.
I would think that your best bet when you don't want the values to change would be to set TickValuesMode to manual.
It also sounds like you want the limits to stay in synch, is that correct? If so, you might want to consider using linkaxes:
ax = [subplot(1,3,1),subplot(1,3,2),subplot(1,3,3)];
set(ax(2:3),'YTickLabels',{})
set(ax,'YGrid','on')
linkaxes(ax,'y')
dpb
on 6 Apr 2016
I could see the position affecting the X axis when removing Y tick labels as there's subsequently more room but don't see why it should affect spacing on the same axis. 'Spearminting here some didn't cause the symptom.
I agree linkaxes may help 'cuz it'll keep ylim the same.
I was mightily confused by OP's reference to LaTex and not seeing the axes creation. My guess was he was putting together three separate figures externally rather than using subplot (which is where I'd've started, too, and I suspect there it will behave as he would expect...but, we need to see a piece of code from OP that generates the issue he's having to be certain, agreed...
Mike Garrity
on 6 Apr 2016
The X & Y aren't actually independent in MATLAB's tickpicker, and the relationship between the two can be rather surprising.
rueckelt
on 6 Apr 2016
dpb
on 6 Apr 2016
@ruekelt -- Move your comment above to Answer; since we didn't have an actual answer there's no way to mark comments as having lead to the result...
@ Mike -- it may be there's some interaction but I don't recall ever having removing tick labels on a given axis doing anything to the tick values or limits. And, here, as suspected, there was a hidden explicit xtick change...but, if something bizzaro does sometime show up I'll keep your warning in mind.
Answers (0)
Categories
Find more on Axis Labels in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!