how to create different plots in the same figure and create different yaxis for all the plots

조회 수: 1 (최근 30일)
i want to create figure like the attach file and create different yaxis in different places. how can i do this?
  댓글 수: 2
jonas
jonas 2018년 9월 1일
편집: jonas 2018년 9월 1일
Is the bottom x-axis (x1/D) actually connected to those lines? Without context I find this graph quite confusing. I suspect this is just three different aligned subplots with the same y- and x-axis where the horizontal location of each subplot has been set to signify increasing x1/D. Why else are there no ticks on the x-axis? Also, the origin is not in the intercept, making it almost impossible to read the value of x1/D over x2/D. However, I'm just guessing here. Need more context to help.
Shay Buzaglo
Shay Buzaglo 2018년 9월 2일
you right, have 3 different locations in x_axis with the same y_axis. thank you

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

답변 (2개)

Star Strider
Star Strider 2018년 9월 1일
편집: Star Strider 2018년 9월 1일
Try something like this:
x = linspace(-2, 2, 50);
y = [10*exp(-2*(x.^2))+10; 10*exp(-4*(x.^2))+20; 10*exp(-8*(x.^2))+30];
figure
hp = plot(x, y);
rotate(hp, [0 0 1], 90)
Experiment to get the result you want. (The ‘trick’ is the rotate call!)
Also see the xlabel (link) and Axes Properties (link) documentation to set the appropriate axis and tick labels for your plot.
Edit
Added plot figure.

jonas
jonas 2018년 9월 1일
As already pointed out by Star Strider, the key is rotate. I just wanted to add this template for reproducing this specific plot, if that's what you're looking to do. Find the resulting graph in the attachment.
% Data
x = 0:.1:2*pi;
y = sin(x);
% Plot template
figure;
% Subplot 1
h(1)=subplot(1,3,1);hold on
hp{1}=plot(x,y)
ylabel('xaxis')
rotate(hp{1},[0 0 1],90)
% Subplot 2
h(2)=subplot(1,3,2);hold on
hp{2}=plot(x,y)
xlabel('yaxis')
rotate(hp{2},[0 0 1],90)
% Subplot 3
h(3)=subplot(1,3,3);hold on
hp{3}=plot(x,y)
rotate(hp{3},[0 0 1],90)
% Axes settings
set(h,'xaxislocation','top','ycolor','none')
hg=axes('color','none','xtick',[],'xticklabels',{})
xlabel('random line')
ylabel('yaxis')
set(gcf,'color','w')
linkaxes([h hg],'y')
linkaxes([h],'x')
dPos=hg.Position-h(1).Position;
for i=1:3
h(i).Position=h(i).Position+[0.05 0 0 dPos(4)];
end
hg.Position=hg.Position+[0 0 0.05 0];

카테고리

Help CenterFile Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by