3

How do I remove the values from the right y-axis in this multiple axis plot? Code source.

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')
Clone
  • 3,378
  • 11
  • 25
  • 41

1 Answers1

1

Setting the YColour attribute of the axis to none may be an implementation to consider. It's good to consider that gca is the most current axis previously called in the code.

Hidden Right Y-Axis

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')
MichaelTr7
  • 4,737
  • 2
  • 6
  • 21