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 Center および File ExchangeCreating, 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