MATLAB Answers

Rikke
0

How to add x-axis in the bottom or in the top of a figure?

Rikke
さんによって質問されました 2019 年 4 月 28 日
最新アクティビティ dpb
さんによって 編集されました 2019 年 4 月 28 日
dpb
さんの 回答が採用されました
I have a graph were I want to have both an x-axis for time and another showing distance.
Is there some easy way to do this? I found a way to easily add an extra y-axis by using yyaxis right, but couldn't find a similar code for adding an extra x-axis.

  0 件のコメント

サインイン to comment.

1 件の回答

dpb
回答者: dpb
2019 年 4 月 28 日
編集済み: dpb
2019 年 4 月 28 日
 採用された回答

Indeed, why after 30 years TMW hasn't built parallel universe for it is simply incomprehensible, I agree. It isn't all that hard, but to continue to force the user to "roll their own" is just plain ruide... :(
Starting with having the existing plot...
hAx1=gca; % get the first axis handle so can address each desired
hAx2=axes('Position',hAx1.Position, ...
'XAxisLocation','top', ...
'YAxisLocation','right', ...
'Color','none', ...
'YTick',[]);
Then, set the 'Xlim','XTick' properties of hAx2 as desired if it is just a scale or plot to the specific axes handle if actually adding data (altho it will then be on the RH axis so I'm guessing that's not what you're doing which is why turned it off)

  0 件のコメント

サインイン to comment.



Translated by