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

Antworten (1)

Dave B
Dave B am 27 Mär. 2022

0 Stimmen

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 Kommentar

Paul Hinze
Paul Hinze am 1 Apr. 2022
Very nice! that what it i was looking for. Thank you

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Hilfe-Center und File Exchange

Tags

Gefragt:

am 26 Mär. 2022

Kommentiert:

am 1 Apr. 2022

Community Treasure Hunt

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

Start Hunting!

Translated by