How to create an empty plotting area, with log X axis?

18 次查看(过去 30 天)
This is the code:
xlim([0.01,100000]);
ylim([0,1]);
grid on
grid minor
axes('XLim',[0.01,100000], 'YLim',[0,2], 'XGrid','on', 'YGrid','on')
yline(1)
set(gca, 'XScale', 'log')
set(gca, 'YTicklabel',[])
yticks([0 1 2])
yticklabels({'0' '1' '2'});
I just want to get rid of the numbers [0 1 2 3 ... 10] on the x axis, and [0.1 0.2 ...1] on the y axis.
Thanks in advance.
  1 个评论
Diwakar Diwakar
Diwakar Diwakar 2023-6-11
xlim([0.01, 100000]);
ylim([0, 1]);
grid on;
grid minor;
axes('XLim',[0.01, 100000], 'YLim',[0, 2], 'XGrid','on', 'YGrid','on');
yline(1);
set(gca, 'XScale', 'log');
set(gca, 'XTick', []); % Remove X tick labels
set(gca, 'YTick', []); % Remove Y tick labels
yticks([0 1 2]);
yticklabels({'0', '1', '2'});

请先登录,再进行评论。

采纳的回答

VBBV
VBBV 2023-6-11
编辑:VBBV 2023-6-11
If you use xlim & ylim it creates an empty plot with axes information having that range specified. Make them empty
xlim([0.01,100000]);
ylim([0,1]);
% call the axes information corresponding to xlim and ylim,
ax = gca;
% set them to empty
set(gca,'YTicklabel',[],'XTicklabel',[])
grid on
grid minor
axes('XLim',[0.01,100000], 'YLim',[0,2], 'XGrid','on', 'YGrid','on')
yline(1)
set(gca, 'XScale', 'log')
set(gca, 'YTicklabel',[])
yticks([0 1 2])
yticklabels({'0' '1' '2'});
  4 个评论
Dyuman Joshi
Dyuman Joshi 2023-6-11
@Housam Mohammad, In case you also want to remove the ticks corresponding to the numbers you mentioned -
xlim([0.01,100000]);
ylim([0,1]);
% call the axes information corresponding to xlim and ylim,
ax = gca;
% set them to empty
set(gca,'YTicklabel',[],'XTicklabel',[])
grid on
grid minor
axes('XLim',[0.01,100000], 'YLim',[0,2], 'XGrid','on', 'YGrid','on')
yline(1)
set(gca, 'XScale', 'log')
set(gca, 'YTicklabel',[])
yticks([0 1 2])
yticklabels({'0' '1' '2'});
set(gca,'XMinorTick','off')
set(gca,'YMinorTick','off')

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Axis Labels 的更多信息

产品


版本

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by