How do I switch x axis by y axis without using 'view'?
1 次查看(过去 30 天)
显示 更早的评论
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!!
0 个评论
采纳的回答
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')
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!