Improving readability of Matlab graph

3 ビュー (過去 30 日間)
Aleem Andrew
Aleem Andrew 2020 年 4 月 5 日
コメント済み: Fego Etese 2020 年 4 月 6 日
The plot generated by the following code appears with the ticks labelled 1 to 25 for the x axis and 0 to 20 for the y axis. I want the ticks to appear but not to be labelled. Does anyone have suggestions as to how I should modify the code?
x=linspace(0,10,100000000);
y = 4*(1-exp(-0.001*x/(1.05*10^-4)));
plot( x,y)
xlim([0 25])
ylim([-20 20])
set(gca,'xtick',-25:1:25)
set(gca,'ytick',-20:1:20)

採用された回答

Adam Danz
Adam Danz 2020 年 4 月 5 日
編集済み: Adam Danz 2020 年 4 月 5 日
Method 1: remove some X|YTickLabels
Add these lines to then end of your code after setting the axis limits and axis ticks.
The tickInterval variable defines the interval of ticks to display.
tickInterval = 4;
ax = gca();
ax.XTickLabel(~ismember(1:numel(ax.XTickLabel), 1:tickInterval:numel(ax.XTickLabel))) = {''};
ax.YTickLabel(~ismember(1:numel(ax.YTickLabel), 1:tickInterval:numel(ax.YTickLabel))) = {''};
Method 2: Use Minor Ticks
This method may not be available on all types of axes.
ax = gca();
ax.XTick = 0:5:25;
ax.YTick = -25:5:25;
ax.XMinorTick = 'on';
ax.XRuler.MinorTickValues = 0:1:25;
ax.YMinorTick = 'on';
ax.YRuler.MinorTickValues = -25:1:25;
Also see ax.XRuler.TickLength to change the tick lengths.
  2 件のコメント
Aleem Andrew
Aleem Andrew 2020 年 4 月 5 日
Thank you for your answer
Fego Etese
Fego Etese 2020 年 4 月 6 日
Hey Adam Danz, please i need your help on this question
I will be grateful if you can help me, thanks

サインインしてコメントする。

その他の回答 (1 件)

Ameer Hamza
Ameer Hamza 2020 年 4 月 5 日
Try this
x=linspace(0,10,100000000);
y = 4*(1-exp(-0.001*x/(1.05*10^-4)));
plot( x,y)
xlim([0 25])
ylim([-20 20])
set(gca,'xtick',-25:1:25, 'XTickLabel', {}) %<--- remove labels
set(gca,'ytick',-20:1:20, 'YTickLabel', {})
  1 件のコメント
Aleem Andrew
Aleem Andrew 2020 年 4 月 5 日
Thank you for your answer

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeLabels and Annotations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by