Как мне удалить значения с одной оси y при наличии нескольких осей?

#matlab #matlab-figure #axes #multiple-axes

#matlab #matlab-рисунок #оси #несколько осей

Вопрос:

Как мне удалить значения с правой оси y на этом графике с несколькими осями? Исходный код.

 figure
x1 = Pmax;
y1 = FuelCons;
line(x1,y1,'Color','r')
ax1 = gca; % current axes

ax1_pos = ax1.Position; % position of first axes
ax2 = axes('Position',ax1_pos,...
    'XAxisLocation','top',...
    'YAxisLocation','right',...
    'Color','none');

x2 = Cdrag;
y2 = FuelCons;
line(x2,y2,'Parent',ax2,'Color','k')
  

Ответ №1:

Установка YColour атрибута оси на none может быть рассмотренной реализацией. Полезно учитывать, что gca это самая текущая ось, ранее вызванная в коде.

Скрытая правая ось Y

 figure

x1 = 0:0.1:40;
y1 = 4.*cos(x1)./(x1 2);
line(x1,y1,'Color','r')
ax1 = gca; % current axes
ax1.XColor = 'r';
ax1.YColor = 'r';

ax1_pos = ax1.Position; % position of first axes
ax2 = axes('Position',ax1_pos,...
    'XAxisLocation','top',...
    'YAxisLocation','right',...
    'Color','none');

set(gca,'YColor','none')