フィルターのクリア

How do I switch x axis by y axis without using 'view'?

3 ビュー (過去 30 日間)
ANA DIAS
ANA DIAS 2021 年 3 月 25 日
コメント済み: ANA DIAS 2021 年 3 月 26 日
Hello,
I'd like to know how can I switch the x axis by y axis without using view ([90 -90]). The view solves my problem, but it doesn't work when I try to add the curves to the histogram.
I need the date in x-axis.
Here's the code.
T = readtable('data1.csv');
dd=T{:,1}; %date (dd/mm/yyyy)
mag=T{:,6};
T_MC = readtable('data2.csv');
dd_MC = t_MC{:,1};
mag_MC = t_MC{:,3};
%Cumulative rate
figure
plot(dd,'b')
hold on
plot(dd_MC,'r')
title('Cumulative Rate')
legend('full', 'full (M >= 1.4)')
%view([90 -90])
hold off
%Histogram
figure
nbins = 192
histogram(dd, nbins, 'facecolor','b')
hold on
histogram(dd_MC, nbins, 'facecolor','r')
xlabel('Date binned by month')
ylabel('N of events')
ylim ([0 80])
yyaxis right
plot(dd,'b')
%view([90 -90])
hold off
Thanks!!

採用された回答

Cris LaPierre
Cris LaPierre 2021 年 3 月 25 日
Specify your x values as your y values, and vice versa
plot(dd,1:length(dd),'b')
hold on
plot(dd_MC,1:length(dd_MC),'r')
  1 件のコメント
ANA DIAS
ANA DIAS 2021 年 3 月 26 日
It worked. Thank you, Cris!!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAnnotations についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by