필터 지우기
필터 지우기

Separate y & x axis

조회 수: 5 (최근 30일)
Paul Hinze
Paul Hinze 2022년 3월 26일
댓글: Paul Hinze 2022년 4월 1일
Hello,
I would like to separate my y- and x-axis, but i did not find any approach to solve this problem.
The problem in this code is, that the vivsible axis doesnt match the data in the figure. This code is only an attempt, to get in touch with this concept.
Here is the code I tried:
clear
clc
tut_fighandle = figure(1);
tut_fighandle.Position(3) = 700;
tut_axis_a = axes;
tut_axis_a.Position(3) = 1;
tut_axis_a.Position(1) = .1;
tut_fighandle.Color = 'White';
set(tut_axis_a,'XColor','White')
% tut_axis_a.Color = 'White';
t = 0:0.1:10;
f1 = 2*sin(t);
f2 = 0.5*cos(t).*exp(-t)+10;
tut_axis_yypre = axes;
[tut_axis_yy, tut_pyy2, tut_pyy3] = plotyy(t,f2,t,f1);
set(tut_axis_yy,'YColor','White')
box off

답변 (1개)

Dave B
Dave B 2022년 3월 27일
There are some submissions on file exchange for this, like this one: https://www.mathworks.com/matlabcentral/fileexchange/57366-separateaxes
Here's a very crude version, this doesn't tie together labels or automatically adjust position, or lots of other niceties, but gives you an idea about how to fake the general effect:
clf
ax=axes('Position',[.12 .12 .85 .85]);
hold on
t=linspace(0,4*pi,100);
plot(ax,sin(t))
ax_x=axes;
ax_x.Position=ax.Position;
ax_x.Position(2)=.07;
ax_x.Position(4)=.00001;
ax_y=axes;
ax_y.Position=ax.Position;
ax_y.Position(1)=.07;
ax_y.Position(3)=.00001;
ax_x.FontSize = ax.FontSize;
ax_y.FontSize = ax.FontSize;
linkprop([ax ax_x],'FontSize');
linkaxes([ax ax_x],'x')
linkprop([ax ax_y],'FontSize');
linkaxes([ax ax_y],'y')
ax.XColor='none';
ax.YColor='none';
ax.XTick=[];
ax.YTick=[];
  댓글 수: 1
Paul Hinze
Paul Hinze 2022년 4월 1일
Very nice! that what it i was looking for. Thank you

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Axis Labels에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by