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';
댓글 수: 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!