How to make axis line invisible but keep ytick and yticklabel visible in double Y-axis figures
5 次查看(过去 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';
0 个评论
采纳的回答
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 Exchange 中查找有关 Big Data Processing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!