Remove or hide the special Y-axis label
3 次查看(过去 30 天)
显示 更早的评论
I have generated some sample data. These are probabilities. My problem with the graphics is that 1.01 is displayed on the Y-axis. But there is no probability that is 1.01. Nevertheless I would like to have this free place. Because if the scaling only goes to 1, then the dots are right at the bottom of the graph, which does not look that good.

Here is my code example:
clear all
clc
x = 2:1:7
y = [1 0.945312500000000 0.961318969726563 0.999182315543294 0.996585680786799 0.999999999320726]
plot(x,y,'o','MarkerSize',5,...
'MarkerEdgeColor','b',...
'MarkerFaceColor','c')
axis([0 8 0.94 1.01])
grid on
0 个评论
采纳的回答
Star Strider
2019-4-24
Change your axis call to:
axis([0 8 0.94 1])
That should do what you want.
7 个评论
Star Strider
2019-4-24
Your 'XTick' values only go from 0 to 8 since you coded them as such. However if you want to use [0 3 6 9], this will plot part of them:
xtix = [0 3 6 9];
set(gca, 'YTick',yt(1:end-1), 'YTickLabel',sprintfc('%.2f',yt(1:end-1)), 'XTick',xtix)
Otherwise, do the same as I did with the 'YTick' and 'YTickLabel' variables to put and name the x-ticks as you like, or change your axis call to go from 0 to 9 on the x-axis.
Steven Lord
2019-4-24
FYI as of release R2016b there are functions xticks, xticklabels, and xtickformat (as well as the corresponding Y and Z axis versions) to help make this type of customization task easier.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Annotations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
