Azzera filtri
Azzera filtri

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

12 visualizzazioni (ultimi 30 giorni)
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 Commento
Diwakar Diwakar
Diwakar Diwakar il 11 Giu 2023
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'});

Accedi per commentare.

Risposta accettata

VBBV
VBBV il 11 Giu 2023
Modificato: VBBV il 11 Giu 2023
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 Commenti
Dyuman Joshi
Dyuman Joshi il 11 Giu 2023
@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')

Accedi per commentare.

Più risposte (0)

Prodotti


Release

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by