Info

この質問は閉じられています。 編集または回答するには再度開いてください。

how to create multiple axis at x axis on same time window? i have attached one image of that kind. Please help.

1 回表示 (過去 30 日間)
Biswajit Ojha
Biswajit Ojha 2018 年 6 月 8 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日

回答 (1 件)

dpb
dpb 2018 年 6 月 9 日
編集済み: dpb 2018 年 6 月 10 日
Start with subplot and mung on it a little...
hSp(1)=subplot(3,1,1); % two subplots in space for three
hSp(2)=subplot(3,1,2);
set(hSp,{'XTick'},{[]});
set(hSp,{'YLim'},{[0.5 1]},{'YTick'},{[0.5:0.1:1]}); % set y limits, clear x ticks
yields
as starting point. You could close up the spacing between the two by retrieving the 'Position' vector for the second and adding a little to the bottom position if desired.
pos=hSp(2).Position; % get position of lower axes
pos(2)=pos(2)+0.05; % add a little to the bottom position
hSp(2).Position=pos; % reset there
Salt to suit...
ADDENDUM
z=exprnd(1,100,1); % first dummy data to plot
RP(:,1)=-z/2/ceil(max(z))+1; % scale roughly same y-axis
z=exprnd(0.1,100,1); % second different parameters
RP(:,2)=-z*0.25+1;
s=linspace(39,45,100); % seconds time array to match
hold(hSp(1),'on') % keep plot() from resetting everything
plot(hSp(1),s,RP,'+') % and plot onto the first axes
ylabel(hSp(1),'Rp') % y axis label
box on % outline
The pattern to follow for the second axes should be clear; use your data variables obviously. The above produced
ADDENDUM 2
And to add the annotation is also fairly straightforward--
hSp(3)=subplot(3,1,3); % make another axes to write into
pos=hSp(3).Position; % retrieve its default position
pos(4)=pos(4)+0.1; % move it up, too
hSp(3).Position=pos; %
xlim(hSp,[39 45]) % apply same x axis range
set(hSp,{'XTick'},{[]}); % various clean up to leave blank
hSp(3).YTick=[]; % canvas to write onto
hSp(3).XColor='none'; hSp(3).YColor='none';
hF=gcf; hF.Color='w';
x=[39:45]; % the values to write at
hTx=text(x,ones(size(x)),num2str(repmat(5.7,7,1)),'Horizontal','center');
hTx=[hTx,text(x,ones(size(x))-0.1,num2str(repmat(5.9,7,1)),'Horizontal','center')];
hTx=[hTx,text(x,ones(size(x))-0.2,num2str(repmat(6.4,7,1)),'Horizontal','center')];
hTx=[hTx,text(x,ones(size(x))-0.3,num2str(x.'),'Horizontal','center')];
r=pos(1)+pos(3); % right side location absolute
pos(3)=0.75*pos(3); % shrink horizontal width
pos(1)=r-pos(3); % find left start point
hSp(3).Position=pos; % and resize to match
l=pos(1);w=pos(3); % save the left and width positions
for i=1:2 % make the other two match up...
pos=hSp(i).Position;
pos(1)=l;pos(3)=w;
hSp(i).Position=pos;
end
ends up with
  2 件のコメント
Biswajit Ojha
Biswajit Ojha 2018 年 6 月 9 日
Dear dvp, thanks a lot for your help. but can you help me how to add multiple variables (LAT, L, MLT etc) plot at x-axis for the same time span as shown in the figure?
dpb
dpb 2018 年 6 月 9 日
You just plot into the desired axes with the x, y values of choice.
See
doc plot
doc subplot
doc hold
for syntax and examples. What, specifically, seems the problem you have?
Have you attempted to make a plot and if so, show us what you've tried...

この質問は閉じられています。

Community Treasure Hunt

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

Start Hunting!

Translated by