Prevent Non-integer Tick Marks
显示 更早的评论
I am writing a library that includes function that plots discrete data that always aligns with integers on the x-axis. Including tick marks at decimal values between integers is potentially confusing to users so I'd like to hide them. How can I prevent MATLAB from adding ticks at non-integer values?
For given axes, it is easy enough to remove all of the tick non-integer tick marks, as follows:
ax = gca();
xtick_values = ax.XTick;
integer_indices = fix(xtick_values) == xtick_values;
ax.XTick = xtick_values(integer_indices);
The problem with this, is that it does not update if a user drags the plot to a region where there are no tick marks.
I would prefer a solution that is compatible back to MATLAB R2014b, but if that's too difficult, I'll take what I can get.
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Polar Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!