How to make axis line invisible but keep ytick and yticklabel visible in double Y-axis figures
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hongyun
am 6 Mär. 2024
Kommentiert: Hongyun
am 12 Mär. 2024
figure
x = linspace(0,10);
y = sin(3*x);
yyaxis left
plot(x,y)
ax = gca;
pause(1e-6)
set(gca,'XColor','k','YColor','k','Color','w',...
'TickLength',[0.01,0.01],'TickDir','out',...
'FontName','Times',...
'TickLabelInterpreter','Latex',...
'LineWidth',1.5,'FontSize',12.5,'FontWeight','Bold',...
'GridLineStyle','-','XGrid','on','YGrid','on');
set(gca,'Color','#EBEBEB','GridColor',[1,1,1],...
'GridAlpha',1,'GridLineWidth',1.1);
% try to hide left-Yaxis line
ax.XRuler.Axle.Visible = 'off';
ax.YRuler.Axle.Visible = 'off';
z = sin(3*x).*exp(0.5*x);
yyaxis right
plot(x,z)
ylim([-150 150])
ax = gca;
pause(1e-6)
set(gca,'XColor','k','YColor','k','Color','w',...
'TickLength',[0.01,0.01],'TickDir','out',...
'FontName','Times',...
'TickLabelInterpreter','Latex',...
'LineWidth',1.5,'FontSize',12.5,'FontWeight','Bold',...
'GridLineStyle','-','XGrid','on','YGrid','on');
set(gca,'Color','#EBEBEB','GridColor',[1,1,1],...
'GridAlpha',1,'GridLineWidth',1.1);
% try to hide right-Yaxis line
ax.XRuler.Axle.Visible = 'off';
ax.YRuler.Axle.Visible = 'off';
0 Kommentare
Akzeptierte Antwort
Ayush Modi
am 12 Mär. 2024
Hi Hongyun,
You can use the "Visible" property for each Y-axis separately to disable the axis-line. Here is an example to demonstrate how you can achieve this:
ax.YAxis(1).Axle.Visible = 'off';
ax.YAxis(2).Axle.Visible = 'off';
Note: There seems to be a bug. This is only working in MATLAB editor. Axis-line is still visible in "Live Editor". You can report it to the Technical Support team by creating a Service Request: https://mathworks.com/support/contact_us.html
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Big Data Processing finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!