How to plot and label a secondary x-axis in log?

8 ビュー (過去 30 日間)
Sammy
Sammy 2021 年 7 月 9 日
コメント済み: Sammy 2021 年 7 月 15 日
I tried to make a secondary x-axis but instead of 10^-3 to 10^1 like the primary x-axis (frequency), I wanted it to be 10^3 to 10^-1 since it should be in days. I tried plotting it using plotxx but I have difficulty getting log values. It should look like this.
figure
ax1=axes;
loglog(freq*24,PSDm,-1./freq/24,NaN*freq)
axis tight
ylim([1e1 1e11])
hold on
ax2=axes;
set(ax2,'Color','none')
set(ax2,'Ytick',[])
set(ax2,'XAxisLocation','top')
% xt = get(ax1,'XTick');
% set(ax2,'XTickLabel',xt)
xlabel(ax1,'frequency [cpd]')
xlabel(ax2,'period [days]')
ylabel(ax1,'kinetic energy density [m^2.s^{-2}/cpd]')
title('JOLO Residual Tides')

採用された回答

Sam
Sam 2021 年 7 月 9 日
編集済み: Sam 2021 年 7 月 9 日
A better way to go about this would be to have two different plots, and in one of them move the x - axis location to the top and do not label the y-axis. Refer to this official documentation provided by Mathworks for the same here
  1 件のコメント
Sammy
Sammy 2021 年 7 月 15 日
Thanks! The plot above is made using plotxx( ) but without the log function. So you have to log the variables first. But thank you still, Sam. (:

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMultirate Signal Processing についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by