How to make axis line invisible but keep ytick and yticklabel visible in double Y-axis figures

6 ビュー (過去 30 日間)
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';

採用された回答

Ayush Modi
Ayush Modi 2024 年 3 月 12 日
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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeBig Data Processing についてさらに検索

タグ

製品


リリース

R2023b

Community Treasure Hunt

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

Start Hunting!