Remove or hide the special Y-axis label

2 ビュー (過去 30 日間)
Lupin Remus
Lupin Remus 2019 年 4 月 24 日
コメント済み: Steven Lord 2019 年 4 月 24 日
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

採用された回答

Star Strider
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
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
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 ExchangeFormatting and Annotation についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by